PRB: CRichEditView, AppWizard View-Based Apps and Compound Files (185282)
The information in this article applies to:
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Visual C++, 32-bit Editions 4.0
- Microsoft Visual C++, 32-bit Editions 4.1
- Microsoft Visual C++, 32-bit Enterprise Edition 4.2
- Microsoft Visual C++, 32-bit Professional Edition 4.2
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q185282 SYMPTOMS
You can experience two problems when you choose compound file support for
an MFC application based on CRichEditView. The first problem also occurs
with MFC applications based on other view classes (eg. CView, CEditView,
and so on): - The document's Serialize function will pass in what seems to be an
invalid CArchive object. For example, if you place the following code in
the Serialize function of an application that includes compound file
support, nothing will appear in the message box:
CFile *pFile = ar.GetFile();
AfxMessageBox(pFile->GetFilePath());
- When you save your document to a file, Word or WordPad will not be able
to correctly read it.
These problems can arise when you use the AppWizard to create single
document interface (SDI) or multiple document interface (MDI) applications,
and when you enable compound file support (in Step 3 of the AppWizard).
Typically, you see a call to EnableCompoundFile() in the constructor of
your CDocument-derived class when this problem occurs.
CAUSE- The CArchive object passed in by the document's Serialize function is
fine. The m_strFileName (file name) member of CArchive is empty because
the compound file support is enabled in the application. The CArchive
object is associated with a COleStreamFile object, which is a wrapper
for a stream object (it supports the IStream interface). This stream
object represents only a part of the compound file, and so the file name
field is empty.
- When you enable compound files in a CrichEditView-based application, the
Rich Text Format (RTF) stream provided is stored in a compound file
layout, which neither Word nor WordPad understands. When you try to
display a compound file with either Word or Wordpad, the files display
as plain text.
RESOLUTION- If you want to use compound files, your code must not try to get
information that isn't defined for a compound file from the CArchive
object.
- If you want your files to be compatible with Word and WordPad, don't
choose compound file support. Word and WordPad can understand the RTF
stream stored in a flat file.
STATUS
This behavior is by design.
REFERENCES
Visual C++ Programmer's Guide: Adding Program Functionality; Details;
Containers: Compound Files.
For additional information, please see the following article in the
Microsoft Knowledge Base:
166769 PRB: MFC ActiveX Document Servers Require Compound File Support
Modification Type: | Major | Last Reviewed: | 12/10/2003 |
---|
Keywords: | kbCodeGen kbDocView kbprb KB185282 |
---|
|