Unveiling visual c ++ Application Framework

Source: Internet
Author: User

Lu yingwei, Department of optoelectronic engineering, Beijing University of Technology
Computer programming skills and maintenance 1999.1 P30

The powerful functions provided by the visual C ++ application framework provide great convenience for our program development. The Application Builder can easily generate the application framework. most common functions, such as document creation, file opening, and saving, are implemented by the application framework. these operations are transparent to software developers. microsoft designed Visual C ++ to provide users with as simple interfaces as possible. However, it is precisely because of the transparency of the application framework that, this makes the running process of Visual C ++ very mysterious. When software development involves the functional modules provided by Visual C ++, users (especially those who are new to Visual C ++) do not know when to use any interface functions, when you want to change some default operations of Visual C ++, you do not know where to start, making development more difficult.
I found in programming practices that I can use VISUAL C ++'s powerful debug debugging tool to track the application framework code and draw some procedures for the application framework operation. the specific implementation is: Use the Visual C ++ Application Builder to generate the application framework code, start classwizard, add the interface function to be tracked in each class, edit the interface function, and set the breakpoint, then start debug for single-step tracking debugging. with this method, we can also trace the sample code provided by Visual C ++. during the tracking process, the core code of Visual C ++ prohibits tracking and debugging. You only need to skip this step.
The following describes how to create a document for a Multi-document application, how to open a file, and how to save it as a trail. The procedure of a Single-document application is similar to that of a Multi-document application, only csingledoctemplate class functions with the same name are used to replace calls to functions with the same name in cmultidoctemplate class. in the following description, "application" refers to the actual program generated by the user based on the application framework, and "User code" refers to the code that the user adds to the interface function.


1. Create a document
On_command (id_file_new, cwinapp: onfilenew)
Entry: cwinapp: onfilenew
Call: cdocmanager: onfilenew ()
1. Determine whether a document template exists. If no template exists, the function returns;
2. Determine whether there are multiple document templates. If yes, enable the Document Template Selection dialog box. After selecting a template, return the template pointer.
3. Access cmultidoctemplate by template pointer: opendocumentfile ()
31. Create a New Document Object
32. Create a sub-framework corresponding to the new document object to build the sub-framework, the relationship between the document and the window
33. Call the onnewdocument () of the application ()
A. Call cdocument: onnewdocument ()
Call deletecontents () of the application ();
B. User code
34. Call initialupdateframe () display window
35. Return document pointer
4. Return

2. Open the document
On_command (id_file_open, cwinapp: onfileopen)
Entry: cwinapp: onfileopen
Call: cdocmanager: onfileopen ()
1. In the dialog box that appears, select the file to be opened and return the full path name of the file for the following function calls.
2. Call the opendocumentfile (lpctstr lpszfilename) of the application)
21. User code
22. Call cwinapp: opendocumentfile (lpszfilename ),
Call cwinapp: opendocumentfile (lpszfilename ),
Call cdocmanager: opendocumentfile
A. Check whether the file has been opened. If yes, activate the window and return
B. Call cmultidoctemplate: opendocumentfile ()
B1. create a new document object and a sub-framework corresponding to the new document object
B2. call the onopendocument () of the application ()
(1) Call cdocument: onopendocument ()
. Open the file object
. Call deletedontents () of the application ();
. Create a carchive object associated with this file object
. Call the serialize () function of the application document object
. Close the carchive object and file object.
(2) display the file window
B3. return

Iii. File Storage
On_command (id_file_save, cdocument: onfilesave)
Entry: cdocument: onfilesave ()
Call: cdocument: dofilesave ()
If the file name corresponding to the current document is null or a read-only file, call cdocument: dosave (null) with null as the parameter. Otherwise, call cdocument: with the corresponding file name as the parameter :: dosave (m_strpathname );

On_command (id_file_saveas, cdocument: onfilesaveas)
Entry: cdocument: onfilesaveas ()
Use null as the parameter to directly call cdocument: dosave (null );
Cdocument: dosave (lpctstr lpszpathname, bool breplace );
If lpszpathname is null,
1. Set the default file name of the application
2. Open the universal file storage dialog box, set the name of the file to be saved, and return the file name.
If lpszpahtname is not null, skip the preceding two steps and go directly to the next step.
3. Call the application's onsavedocument ()
31. User code
32. Call cdocument: onsavedocument ()
A. Create or open a file object
B. Create the corresponding carchive object
C. Call the serialization function serialize () of the application documentation object ()
D. close the file object and carchive object
E. Set the file flag not modified
4. Return

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.