Okay,
so i started a project with a rich edit view, richedit doc and such..
but I also create another Cricheditctrl object in this program. I'm trying to serialize it in Document class serialize function.
is this even okay to do?
as i said..Code:void CProject5Doc::Serialize(CArchive& ar) { CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd(); CFile *file = ar.GetFile(); CString cname=file->GetFilePath(); // I like seeing the full pathname as a title. SetTitle(cname); if (cname.Right(4) == ".rtf") { // No change for rtf files //CRichEditDoc::Serialize(ar); pMainWnd->m_edit.Serialize(ar); } else { // Treat as flat text files CString cstr; // CRichEditDoc will only work with one CRichEditView // class. CView *pView = GetView(); // GetView is equavalent to: // POSITION pos; //pos = GetFirstViewPosition(); //CView *pView= GetNextView(pos); if (ar.IsStoring()) { // GetWindowText will grab all of the displayed text (no formatting) pView->GetWindowText(cstr); // Should probably have try ... catch logic file->Write(cstr, cstr.GetLength()); } else { int nSize = file->GetLength(); char *pBuff = new char[nSize+1]; if (pBuff != NULL) { // The following should probably have TRY ... Catch logic file->Read(pBuff, nSize); pBuff[nSize] = 0; cstr = pBuff; // The following will update the display text on the screen // again formatting is missing. pView->SetWindowText(cstr); delete pBuff; } } } // /* CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd(); if (ar.IsStoring()) { pMainWnd->m_edit.Serialize(ar); // TODO: add storing code here } else { // 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::Serialize(ar);*/ }
pMainWnd->m_edit.Serialize(ar); the m_edit is a Cricheditctrl objct.
what i have above is not working.. and i'm not sure why it's not.



LinkBack URL
About LinkBacks


