Share via


CArchive::m_pDocument

Set to NULL by default, this pointer to a CDocument can be set to anything the user of the CArchive instance wants.

CDocument* m_pDocument;

Remarks

A common usage of this pointer is to convey additional information about the serialization process to all objects being serialized. This is achieved by initializing the pointer with the document (a CDocument-derived class) that is being serialized, in such a way that objects within the document can access the document if necessary. This pointer is also used by COleClientItem objects during serialization.

The framework sets m_pDocument to the document being serialized when a user issues a File Open or Save command. If you serialize an Object Linking and Embedding (OLE) container document for reasons other than File Open or Save, you must explicitly set m_pDocument. For example, you would do this when serializing a container document to the Clipboard.

Example

CFile myFile(_T("My__test__file.dat"), 
   CFile::modeCreate | CFile::modeWrite);
CArchive ar(&myFile, CArchive::store);
CMyDocument mydoc;
ar.m_pDocument = &mydoc;

// Serialize the document to the archive. 
if (ar.m_pDocument != NULL)
   ar.m_pDocument->Serialize(ar);                    

Requirements

Header: afx.h

See Also

Reference

CArchive Class

Hierarchy Chart

CDocument Class

COleClientItem Class