Skip to content

Latest commit

 

History

History
53 lines (48 loc) · 2.62 KB

File metadata and controls

53 lines (48 loc) · 2.62 KB
title Document Template Creation | Microsoft Docs
ms.custom
ms.date 11/04/2016
ms.reviewer
ms.suite
ms.technology
cpp-windows
ms.tgt_pltfrm
ms.topic article
dev_langs
C++
helpviewer_keywords
document templates
constructors [C++], document template
document templates, creating
MFC, document templates
templates, document templates
ms.assetid c87f1821-7cbf-442e-9690-f126ae7fb783
caps.latest.revision 9
author mikeblome
ms.author mblome
manager ghogen
translation.priority.ht
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

Document Template Creation

When creating a new document in response to a New or Open command from the File menu, the document template also creates a new frame window through which to view the document.

The document-template constructor specifies what types of documents, windows, and views the template will be able to create. This is determined by the arguments you pass to the document-template constructor. The following code illustrates creation of a CMultiDocTemplate for a sample application:

[!code-cppNVC_MFCDocView#7]

The pointer to a new CMultiDocTemplate object is used as an argument to AddDocTemplate. Arguments to the CMultiDocTemplate constructor include the resource ID associated with the document type's menus and accelerators, and three uses of the RUNTIME_CLASS macro. RUNTIME_CLASS returns the CRuntimeClass object for the C++ class named as its argument. The three CRuntimeClass objects passed to the document-template constructor supply the information needed to create new objects of the specified classes during the document creation process. The example shows creation of a document template that creates CScribDoc objects with CScribView objects attached. The views are framed by standard MDI child frame windows.

See Also

Document Templates and the Document/View Creation Process
Document/View Creation
Relationships Among MFC Objects
Creating New Documents, Windows, and Views