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.

The words "456" is lose...

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...
I press save 123.txt through OnSaveDocument , then i open 123.txt
The words and format are error.

The words "456" is lose...

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...