Review of SDI Program creation process
Starting from cwinapp. initialinstance,
1. First, create a document template for the Application object;
Csingledoctemplate * pdoctemplate;
Pdoctemplate = new csingledoctemplate (
Idr_mainframe,
Runtime_class (csdicoindoc ),
Runtime_class (cmainframe), // main SDI frame window
Runtime_class (csdicoinview ));
2. document templates create document objects, open or create files;
Ccommandlineinfo prepare Info; // class for Processing Command Line Information
Enum {filenew, fileopen, fileprint, fileprintto, filedde, appunregister, filenothing =-1} nshellcommand; // 7 Action types
Ccommandlineinfo: ccommandlineinfo () // default constructor of the ccommandlineinfo class
{
M_bshowsplash = true;
M_brunembedded = false;
M_brunautomated = false;
M_nshellcommand = filenew; // specifies the shell command operation (default action)
}
Parsecommandline (cmdinfo); // call cwinapp: processshellcommand () to execute the corresponding action based on the nshellcommand value above.
Filenew ---> onfilenew ();
Fileopen ---> opendocumentfile ();
Fileprint, fileprintto ---> ......
Filedde --->...
Appunregister --->...
....
3. Create a border window object and a border window in the Document Template;
4. Create the view object and window port for the border window object.
The following uses the filenew action as an example to illustrate the creation process:
A. Call onfilenew (m_pdocmanager-> onfilenew (), a member function of the Document Template manager ());
B. The template manager obtains the document template object pointer and calls the opendocumentfile function (ptemplate-> opendocumentfile (null) of the document template object )).
C. If the template manager finds multiple document templates, a dialog box is displayed to allow the user to select a document template.
D. csingledoctemplate: opendocumentfile ();
// Create a document class
Cdocument * pdocument = createnewdocument ();
// Create a framework class
Cframewnd * pframe = createnewframe (pdocument, null );
E. Call the virtual function initialupdateframe of cframewnd to complete window initialization;
These creation processes are centered on application document templates. When creating these MFC objects, the relationship between them is established. After these settings are created, initialize them, activate the main border window, and display the border window and window port.
In this way, an SDI application completes the startup process and waits for user interaction or input.