Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

having trouble opening up big files

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
rpete
Asked:
rpete
  • 2
  • 2
1 Solution
 
rpbCommented:
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
 
rpeteAuthor Commented:
/////////////////////////////////////////////////////////////////////////////
// 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
 
rpbCommented:
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
 
rpeteAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now