Solved

having trouble opening up big files

Posted on 1997-07-10
4
251 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
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 163
wordmultiple challenge 12 142
Excel file not created as expected 7 79
x-bar in Google Sheets 2 72
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

820 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