Your browser doesn't support JavaScript Multi Document Interface - Windows Programming

Multi Document Interface

Multiple-document interface applications enable the user to work with more than one document simultaneously. Each document is displayed within a separate child window within the client area. An MDI child window looks much like a typical frame window, except that the MDI child window appears inside an MDI frame window and does not have a dedicated menu bar, but instead shares the menu of the MDI frame window. The framework automatically changes the MDI frame menu to represent the active MDI child window.

In addition to the 3 classes found in an SDI application, an MDI application must derive a class from CMDIChildWnd which provides the functionality for the Windows multiple document interface (MDI) child window. To make a document different from its parent, the application will also require additional resources to those associated with the main window.

A Multiple Document Interface (MDI) application uses the CMultiDocTemplate class derived from CdocTemplate.

If the MDI application uses more than one type of document then a separate template must be supplied for each document. This will require a separate template for each type of document using a CDocMultiDocTemplate constructor for each.

Working with Multiple-Document Types

By default, an SDI or an MDI application, created with the AppWizard will be configured with only a single document class. Additional document class types can however be added by making a second call to AddDocTemplate() in the application class InitInstance() member function as outlined below –

CMultiDocTemplate* pDocTemplate; PDocTemplate = new CMultiDocTemplate(IDR_SAMPLE1, RUNTIME_CLASS(CSample1Doc), RUNTIME_CLASS(CMDIChildWnd), RUNTIME_CLASS(CSample1View)); AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate( IDR_SAMPL2, RUNTIME_CLASS(CSample2Doc), RUNTIME_CLASS(CMDIChildWnd), RUNTIME_CLASS(CSample2View)); AddDocTemplate(pDocTemplate);

The type of document to create can then be selected via the main menu.

Example

The application below allows the user to create a multi-document interface based on the CeditView view class

Download Code