Share via


Creating Document Frame Windows

OverviewHow Do ITutorial

Document/View Creation shows how the object orchestrates creating the frame window, document, and view and connecting them all together. Three arguments to the CDocTemplate constructor specify the frame window, document, and view classes that the document template creates dynamically in response to user commands such as the New command on the File menu or the New Window command on an MDI Window menu. The document template stores this information for later use when it creates a frame window for a view and document.

For the mechanism to work correctly, your derived frame-window classes must be declared with the macro. This is because the framework needs to create document frame windows using the dynamic construction mechanism of class CObject.

When the user chooses a command that creates a document, the framework calls upon the document template to create the document object, its view, and the frame window that will display the view. When it creates the document frame window, the document template creates an object of the appropriate class—a class derived from for an SDI application or from for an MDI application. The framework then calls the frame-window object’s member function to get creation information from resources and to create the Windows window. The framework attaches the window handle to the frame-window object. Then it creates the view as a child window of the document frame window.

Use caution in deciding when to initialize your CWnd-derived object.

What do you want to know more about?