|
I use CRichEditView to write a text editor, store the characters in CString, and want to write it into a plain text. But after doing the following, the resulting file always has a complicated garbled beginning. What should I do?
void CLispEditorDoc :: Serialize (CArchive&ar)
{
POSITION pos = GetFirstViewPosition ();
CRichEditView * pFirstView = (CRichEditView *) GetNextView (pos);
CRichEditCtrl * pCtrl =&pFirstView-> GetRichEditCtrl ();
pCtrl-> GetWindowText (m_text);
// AfxMessageBox (m_text);
Ranch
if (ar.IsStoring ())
{
ar << m_text; // TODO: add storing code here
}
else
{
ar >> m_text; // TODO: add loading code here
}
// Calling the base class CRichEditDoc enables serialization
// of the container document's COleClientItem objects.
// TODO: set CRichEditDoc :: m_bRTF = FALSE if you are serializing as text
CRichEditDoc :: m_bRTF = FALSE;
CRichEditDoc :: Serialize (ar);
} |
|