Visual Studio MFC MDI , OnSaveDocument format error

  • Thread starter Thread starter gsegria
  • Start date Start date
G

gsegria

Guest
I create MFC MDI project on CRichEditView / CRichEditDoc.

I press save 123.txt through OnSaveDocument , then i open 123.txt

The words and format are error.



1577100.jpg


The words "456" is lose...

1577099.png




Here is my code:
BOOL CMyEditDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
m_bRTF = FALSE;

CString allcode;
CRichEditView* pView = GetView();
if (NULL == pView)
return false;
CRichEditCtrl& edit = pView->GetRichEditCtrl();
edit.GetWindowText(allcode);

CFile file;
int length = allcode.GetLength();
try
{
file.Open(lpszPathName, CFile::modeCreate | CFile::modeWrite);
file.Write((LPCTSTR)allcode, length);
file.Close();
}
catch (CFileException* e)
{
ASSERT(false);
e->m_cause;
return false;
}
SetModifiedFlag(false);
return true;
}

Continue reading...
 
Back
Top