You can add forms to any Visual C++ application that supports the MFC libraries, including a forms-based application (one whose view class is derived from CFormView). If you didn't initially create your application to support forms, Visual C++ will add this support for you when you insert a new form. In an SDI or MDI application, which implements the default document/view architecture, when the user chooses the New command (by default, on the File menu), Visual C++ prompts the user to choose from the available forms.
With an SDI application, when the user chooses the New command, the current instance of the form closes and the user can open another instance of that form or any other available form. In an MDI application, the current instance of the form continues to run when the user chooses the New command.
Note You can insert a form into a dialog-based application (one whose dialog class is based on CDialog and one in which no view class is implemented). However, without the document/view architecture, Visual C++ does not automatically implement the File|New functionality. You must create a way for the user to view additional forms, such as by implementing a tabbed dialog box with various property pages.
When you insert a new form into your application, Visual C++ does the following:
For programs without a document/view architecture (this includes dialog-based applications and ATL programs with MFC support), the initial base class is always CDialog.
If you choose an existing dialog resource, you may need to set these styles by using the Properties page for the dialog box. Styles for a dialog box must include:
WS_CHILD=On
WS_BORDER=Off
WS_VISIBLE=Off
WS_CAPTION=Off
For applications based on the document/view architecture, the New Form command also:
You can choose, instead of having a new class created, to use any existing CDocument-based class in your project.
You can also create a new class on which to base the template.
Visual C++ adds this code for each new form you create, which adds the form to the list of available forms when the user chooses the New command. This code includes the form's associated resource ID, and the names of the associated document, view, and frame classes that together make up the new form object.
Document templates serve as the connection between documents, frame windows, and views. For a single document, you can create many templates.