Skip to content

Latest commit

 

History

History
36 lines (25 loc) · 3.97 KB

creating-new-documents-windows-and-views.md

File metadata and controls

36 lines (25 loc) · 3.97 KB
description title ms.date helpviewer_keywords ms.assetid
Learn more about: Creating New Documents, Windows, and Views
Creating New Documents, Windows, and Views
11/19/2018
MDI [MFC], creating windows
window objects [MFC], creating
objects [MFC], creating document objects
MFC default objects
frame windows [MFC], creating
windows [MFC], MDI
MFC, documents
view objects [MFC], creating
windows [MFC], creating
overriding, default view behavior
views [MFC], initializing
customizing MFC default objects
MFC, frame windows
MFC, views
MDI [MFC], frame windows
child windows [MFC], creating MDI
view objects [MFC]
document objects [MFC], creating
MFC default objects [MFC], customizing
views [MFC], overriding default behavior
initializing views [MFC]
88aa1f5f-2078-4603-b16b-a2b4c7b4a2a3

Creating New Documents, Windows, and Views

The following figures give an overview of the creation process for documents, views, and frame windows. Other articles that focus on the participating objects provide further details.

Upon completion of this process, the cooperating objects exist and store pointers to each other. The following figures show the sequence in which objects are created. You can follow the sequence from figure to figure.

Diagram showing the sequence for creating a document.
Sequence in Creating a Document

Diagram showing the Frame Window creation sequence.
Sequence in Creating a Frame Window

Diagram showing the sequence for creating a view.
Sequence in Creating a View

For information about how the framework initializes the new document, view, and frame-window objects, see classes CDocument, CView, CFrameWnd, CMDIFrameWnd, and CMDIChildWnd in the MFC Library Reference. Also see Technical Note 22, which explains the creation and initialization processes further under its discussion of the framework's standard commands for the New and Open items on the File menu.

Initializing Your Own Additions to These Classes

The preceding figures also suggest the points at which you can override member functions to initialize your application's objects. An override of OnInitialUpdate in your view class is the best place to initialize the view. The OnInitialUpdate call occurs immediately after the frame window is created and the view within the frame window is attached to its document. For example, if your view is a scroll view (derived from CScrollView rather than CView), you should set the view size based on the document size in your OnInitialUpdate override. (This process is described in the description of class CScrollView.) You can override the CDocument member functions OnNewDocument and OnOpenDocument to provide application-specific initialization of the document. Typically, you must override both since a document can be created in two ways.

In most cases, your override should call the base class version. For more information, see the named member functions of classes CDocument, CView, CFrameWnd, and CWinApp in the MFC Library Reference.

See also

Document Templates and the Document/View Creation Process
Document Template Creation
Document/View Creation
Relationships Among MFC Objects