Solved

having trouble opening up big files

Posted on 1997-07-10
4
252 Views
Last Modified: 2013-11-20
The code generated by AppWizard can't seem to open big files (file size greater than 60K).  Why is that?  What can I do so that the editor dervied from CEditView can accept big files?
Thanks in advance,
Peter
0
Comment
Question by:rpete
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Expert Comment

by:rpb
ID: 1302525
Are you using 16-bit or 32-bit MFC?  In 16-bit Windows, an edit box (which the CEditView, or a normal view to which you have added a resizing edit box, uses) can only hold 64k.

In 32-bits, you can use the SerializeRaw() method of CEdit to load up your file - I have certainly used this to load up bigger files than 64k.  Normally you save your data in your document, but using this method you can just use the Edit box to "store" your data, and call the SerializeRaw() method on the edit box in your view from your CDocument's Serialize() method.
0
 

Author Comment

by:rpete
ID: 1302526
/////////////////////////////////////////////////////////////////////////////
// CMinieditDoc serialization
I am using 32-bit MFC.  Now the code is the standard one generated by the AppWizard and it's called when the Open button is pushed.  I have attached the portion of the code that's generated by the AppWizard.  Notice that it's using SerializeRaw().  Again, when I try to open a file > 64KB it wouldn't do it.   I remeber reading from somewhere that the editor dervied from CEditView indeed can NOT load files > 64KB.  Any rememdies for this drawback?  If so, can you provide me with an example code with the answer?

Thanks in advance,
Peter


void CMinieditDoc::Serialize(CArchive& ar)
{
      // CEditView contains an edit control which handles all serialization
      ((CEditView*)m_viewList.GetHead())->SerializeRaw(ar);
}

0
 

Accepted Solution

by:
rpb earned 20 total points
ID: 1302527
CStrings and Edit boxes can hold > 64k in 32-bits, so you could try the following (in pseudocode)

Open file file (using CFile or your favourite file function)
Find the length of the file: DWORD size = CFile::GetLength();
Allocate this much memory: LPSTR buff = new char[size + 1];
Read in the data:  file->ReadHuge(buff, size);
You may need to add a null to the end:  buff[size] = '\0';
(Close the file if necessary)
Get ehe Edit control from the view:  pView->GetEditControl()
Load up the edit box with the data:  pEdit->SetWindowText(buff);
Clean up memory:  delete [] buff;


You would have to do a similar thing on saving - GetWindowText, and then spool to file.

To do this, you might want to bypass the normal serialisation, and do this in another CDocument member function, such as OnOpenDocument()

By doing all this yourseld, you should bypass any limits in the default MFC implementation.
0
 

Author Comment

by:rpete
ID: 1302528
Do you have some actually code that you can paste within your reply?  I tried the suggestions that you gave but I am keep getting assertions errors.


Thanks in advance,
Peter
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 59
Different colored text in ComboBox without Subclassing 8 76
wait notify demo infinite loop 3 150
Problem to App source 6 120
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question