BUG: Can't Serialize Items After CRichEditDoc::SerializeLast reviewed: July 10, 1997Article ID: Q138632 |
4.00 4.10 4.20
WINDOWS NT
kbprg kbbuglist kbcode
The information in this article applies to:
SYMPTOMSAn attempt to load a CRichEditDoc causes the following message to appear:
Unexpected file format.This happens when you attempt to serialize data to the archive after serializing the CRichEditDoc.
CAUSECRichEditDoc::Serialize() relies on the rich edit control's support for saving data. The assumption made by MFC is that the serialization of a rich edit control will encapsulate an entire file. The serialization code for loading from the CArchive starts from the current file position and reads to the end of the file. An attempt to load anything after loading the CRichEditDoc fails because the file pointer is at the end of the file.
RESOLUTIONIf you need to store additional data in the archive, serialize it before serializing the CRichEditDoc. Ensure that the CRichEditDoc is serialized last. For example:
void CMyRichEditDoc::Serialize(CArchive& ar){ if (ar.IsStoring()) { ar << m_str1; } else { ar >> m_str1; } // Calling the base class CRichEditDoc enables serialization // of the container document's COleClientItem objects. CRichEditDoc::Serialize(ar); // Do not use CArchive after calling CRichEditDoc::Serialize.}
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
|
Additional reference words: 4.00 4.10 4.20 vcbuglist400
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |