|
我使用CRichEditView写一个文本编辑器,把其中的字符用CString存储起来,并想写入一个纯文本中,可是做了以下操作之后,得到的文件总是带有一个复杂的乱码的开头,请问该怎么办啊?
void CLispEditorDoc::Serialize(CArchive& ar)
{
POSITION pos = GetFirstViewPosition();
CRichEditView* pFirstView =(CRichEditView*) GetNextView( pos );
CRichEditCtrl *pCtrl = &pFirstView->GetRichEditCtrl();
pCtrl->GetWindowText(m_text);
// AfxMessageBox(m_text);
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);
} |
|