Solved

having trouble opening up big files

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now