CDocTemplate Class
An abstract base class that defines the basic functionality for document templates.
class CDocTemplate : public CCmdTarget
Members
Protected Constructors
Name |
Description |
---|---|
Constructs a CDocTemplate object. |
Public Methods
Name |
Description |
---|---|
Adds a document to a template. |
|
Closes all documents associated with this template. |
|
Creates a new document. |
|
Creates a new frame window containing a document and view. |
|
Creates an OLE-enabled frame window. |
|
Creates a child frame used for Rich Preview. |
|
Retrieves a string associated with the document type. |
|
Retrieves the position of the first document associated with this template. |
|
Retrieves a document and the position of the next one. |
|
Initializes the frame window, and optionally makes it visible. |
|
Loads the resources for a given CDocTemplate or derived class. |
|
Determines the degree of confidence in the match between a document type and this template. |
|
Opens a file specified by a pathname. |
|
Removes a document from a template. |
|
Saves all documents associated with this template which have been modified. |
|
Determines the resources for OLE containers when editing an in-place OLE item. |
|
Displays the default title in the document window's title bar. |
|
Setups out of process preview handler. |
|
Determines the resources and classes when the server document is embedded or edited in-place. |
Remarks
You usually create one or more document templates in the implementation of your application's InitInstance function. A document template defines the relationships among three types of classes:
A document class, which you derive from CDocument.
A view class, which displays data from the document class listed above. You can derive this class from CView, CScrollView, CFormView, or CEditView. (You can also use CEditView directly.)
A frame window class, which contains the view. For a single document interface (SDI) application, you derive this class from CFrameWnd. For a multiple document interface (MDI) application, you derive this class from CMDIChildWnd. If you don't need to customize the behavior of the frame window, you can use CFrameWnd or CMDIChildWnd directly without deriving your own class.
Your application has one document template for each type of document that it supports. For example, if your application supports both spreadsheets and text documents, the application has two document template objects. Each document template is responsible for creating and managing all the documents of its type.
The document template stores pointers to the CRuntimeClass objects for the document, view, and frame window classes. These CRuntimeClass objects are specified when constructing a document template.
The document template contains the ID of the resources used with the document type (such as menu, icon, or accelerator table resources). The document template also has strings containing additional information about its document type. These include the name of the document type (for example, "Worksheet") and the file extension (for example, ".xls"). Optionally, it can contain other strings used by the application's user interface, the Windows File Manager, and Object Linking and Embedding (OLE) support.
If your application is an OLE container and/or server, the document template also defines the ID of the menu used during in-place activation. If your application is an OLE server, the document template defines the ID of the toolbar and menu used during in-place activation. You specify these additional OLE resources by calling SetContainerInfo and SetServerInfo.
Because CDocTemplate is an abstract class, you cannot use the class directly. A typical application uses one of the two CDocTemplate-derived classes provided by the Microsoft Foundation Class Library: CSingleDocTemplate, which implements SDI, and CMultiDocTemplate, which implements MDI. See those classes for more information on using document templates.
If your application requires a user-interface paradigm that is fundamentally different from SDI or MDI, you can derive your own class from CDocTemplate.
For more information on CDocTemplate, see Document Templates and the Document/View Creation Process.
Inheritance Hierarchy
CDocTemplate
Requirements
Header: afxwin.h