共用方式為


CDocTemplate Class

An abstract base class that defines the basic functionality for document templates.

class CDocTemplate : public CCmdTarget

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.

Requirements

Header: afxwin.h

See Also

Concepts

CDocTemplate Members

CCmdTarget Class

Hierarchy Chart

CSingleDocTemplate Class

CMultiDocTemplate Class

CDocument Class

CView Class

CScrollView Class

CEditView Class

CFormView Class

CFrameWnd Class

CMDIChildWnd Class