Review of SDI Program creation process in MFC

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.