Solved

having trouble opening up big files

Posted on 1997-07-10
4
246 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
Comment Utility
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
Comment Utility
/////////////////////////////////////////////////////////////////////////////
// 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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 …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

771 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

9 Experts available now in Live!

Get 1:1 Help Now