CDocument Class
Provides the basic functionality for user-defined document classes.
class CDocument : public CCmdTarget
Members
Public Constructors
Name |
Description |
---|---|
Constructs a CDocument object. |
Public Methods
Name |
Description |
---|---|
Attaches a view to the document. |
|
Initializes chunk reading. |
|
Advanced overridable; called before closing a frame window viewing this document. |
|
Clears the chunk list. |
|
Clears the path of the document object. |
|
Called to perform cleanup of the document. |
|
Looks for a chunk with specified GUID. |
|
Returns a pointer to object implementing IDocument interface. |
|
Returns a pointer to the document template that describes the type of the document. |
|
Returns a pointer to the desired CFile object. |
|
Returns the position of the first in the list of views; used to begin iteration. |
|
Iterates through the list of views associated with the document. |
|
Returns the path of the document's data file. |
|
Called to create a bitmap to be used by thumbnail provider to display thumbnail. |
|
Returns the document's title. |
|
Called to initialize search content for Search Handler. |
|
Indicates whether the document has been modified since it was last saved. |
|
Tells whether this instance of CDocument object was created for Search & Organize handler. |
|
Called to load document data from stream. |
|
Called before Rich Preview font is changed. |
|
Called after a view is added to or removed from the document. |
|
Called to close the document. |
|
Called by the framework when it needs to create a preview frame for Rich Preview. |
|
Called by the framework in response to a document event. |
|
Override this method in a derived class to draw content of thumbnail. |
|
Called by the framework when it needs to load the document data from stream. |
|
Called to create a new document. |
|
Called to open an existing document. |
|
Directs the preview handler to return the HWND from calling the GetFocus Function. |
|
Directs the preview handler to handle a keystroke passed up from the message pump of the process in which the preview handler is running. |
|
Called when Rich Preview background color has changed. |
|
Called when Rich Preview font has changed. |
|
Called when Rich Preview site has changed. |
|
Called when Rich Preview text color has changed. |
|
Called to save the document to disk. |
|
Called by the framework when the preview handler is being unloaded. |
|
Called before the frame window is closed. |
|
Reads next chunk value. |
|
Releases a file to make it available for use by other applications. |
|
Removes a chunk with specified GUID. |
|
Detaches a view from the document. |
|
Advanced overridable; called when an open or save operation cannot be completed because of an exception. |
|
Advanced overridable; called to ask the user whether the document should be saved. |
|
Sets a chunk value. |
|
Sets a flag indicating that you have modified the document since it was last saved. |
|
Sets the path of the data file used by the document. |
|
Sets the document's title. |
|
Notifies all views that document has been modified. |
Protected Methods
Name |
Description |
---|---|
Sends a mail message with the document attached. |
|
Enables the Send Mail command if mail support is present. |
Public Data Members
Name |
Description |
---|---|
Specifies that CDocument object was created by dllhost for thumbnails. Should be checked in CView::OnDraw. |
|
Specifies that CDocument object was created by prevhost for Rich Preview. Should be checked in CView::OnDraw. |
|
Specifies that CDocument object was created by indexer or other search application. |
|
Specifies background color of Rich Preview window. This color is set by host. |
|
Specifies foreground color of Rich Preview window. This color is set by host. |
|
Specifies text font for Rich Preview window. This font information is set by host. |
Remarks
A document represents the unit of data that the user typically opens with the File Open command and saves with the File Save command.
CDocument supports standard operations such as creating a document, loading it, and saving it. The framework manipulates documents using the interface defined by CDocument.
An application can support more than one type of document; for example, an application might support both spreadsheets and text documents. Each type of document has an associated document template; the document template specifies what resources (for example, menu, icon, or accelerator table) are used for that type of document. Each document contains a pointer to its associated CDocTemplate object.
Users interact with a document through the CView object(s) associated with it. A view renders an image of the document in a frame window and interprets user input as operations on the document. A document can have multiple views associated with it. When the user opens a window on a document, the framework creates a view and attaches it to the document. The document template specifies what type of view and frame window are used to display each type of document.
Documents are part of the framework's standard command routing and consequently receive commands from standard user-interface components (such as the File Save menu item). A document receives commands forwarded by the active view. If the document doesn't handle a given command, it forwards the command to the document template that manages it.
When a document's data is modified, each of its views must reflect those modifications. CDocument provides the UpdateAllViews member function for you to notify the views of such changes, so the views can repaint themselves as necessary. The framework also prompts the user to save a modified file before closing it.
To implement documents in a typical application, you must do the following:
Derive a class from CDocument for each type of document.
Add member variables to store each document's data.
Implement member functions for reading and modifying the document's data. The document's views are the most important users of these member functions.
Override the CObject::Serialize member function in your document class to write and read the document's data to and from disk.
CDocument supports sending your document via mail if mail support (MAPI) is present. See the articles MAPI and MAPI Support in MFC.
For more information on CDocument, see Serialization, Document/View Architecture Topics, and Document/View Creation.
Inheritance Hierarchy
CDocument
Requirements
Header: afxwin.h