Home | Overview | How Do I | Sample | Tutorial
MFC applications normally use the document/view architecture to manage information, file formats, and the visual representation of data to users. For the majority of desktop applications, the document/view architecture is an appropriate and efficient application architecture. This architecture separates data from viewing and, in most cases, simplifies your application and reduces redundant code.
However, the document/view architecture is not appropriate for some situations. Consider these examples:
To create an application that does not use the document/view architecture, clear the Document/View architecture support check box in step 1 of the MFC AppWizard. See The MFC AppWizard (EXE version): Step-by-Step for details on the MFC AppWizard.
Note Dialog-based applications produced by AppWizard do not use the document/view architecture, so the Document/View architecture support check box is disabled if you select the dialog application type.
The Visual C++ wizards, as well as the source and dialog editors, work with the generated application just as they would with any other Wizard-generated application. The application can support toolbars, scrollbars, and a status bar, and has an About box. Your application will not register any document templates, and it will not contain a document class.
Note that your generated application has a view class, CChildView, derived from CWnd. MFC creates and positions one instance of the view class within the frame windows created by your application. MFC still enforces using a view window, because it simplifies positioning and managing the application's content. You can add painting code to the OnPaint member of this class. Your code should add scrollbars to the view rather than to the frame.
Because the document/view architecture provided by MFC is responsible for implementing many of an application's basic features, its absence in your project means that you are responsible for implementing many important features of your application:
It is strongly recommended that you use the MFC AppWizard to create applications without the document/view architecture, because the AppWizard guarantees a correct MFC architecture. However, if you must avoid using the AppWizard, here are several approaches for bypassing the document/view architecture in your code:
Declared in CDocument:
Additionally, the document requires the amount of time to create the document object, its view objects, a frame window, and a document template object.
The article MFC: Using Database Classes Without Documents and Views gives more concrete examples of document/view alternatives in the context of database applications.