VC application framework

zhaozj2021-02-16  99

The powerful feature provided by the VC application framework provides great convenience to our development, using it easy to generate an application framework. Many common functions, such as the creation of documents, open, saving, etc. Some code is done by the application framework. These operations are transparent to users of the development software. Microsoft Design Visual C 's original intention is to provide users with simple interfaces as possible, but it is because of this transparency of the application framework, so that the VC's running process is very mysterious, and the software that involves these VCs already provided. When developing, users (especially those who have just contacted VC) don't know when to use what interface functions, I want to change some of the default operations of the VC, I don't know where to start. We can track the application framework code through the powerful debug commissioning tool that comes with the VC, which depends on the partial flow of the application framework operation. The specific implementation is: use the Visual C application generator to generate the application framework code, start ClassWizard, Added interface functions to be tracked in each class, edit interface functions, set breakpoints, and then start Debug for single-step tracking debugging. Use this method, we can also track the example code provided by VC. During the tracking process, VC The core code is forbidden to track debugging, we just skip. The following is the follow-up result of the documentation, the file is opened, saved (saving (saving (saving (saving (saving) operation, is basically similar to the operation process of multi-document application, only csingleDectemplate The same name function of the class replaces the call to the CMULTIDOCTEMPLATE class function.

I. Creating a document ON_COMMAND (ID_FILE_NEW, CWINAP: CWINAPP: ONFileNewApp: CDOCManager :: onfilenew () 1. Judging whether there is a document template without a function return; 2. Judgment There are multiple document templates. If you start the Document Template Select dialog, let the user select a template to return to the template pointer. 3. Access the CMULTIDEMPLATE :: OpenDocumentFile () 3.1 Create a new document object 3.2 Create a new document object 3.2 Create a new document object 3.2 Create a new document object The corresponding sub-frame, a structural sub-frame, document, and a window 3.3 calling the application's OnNewDocument () a. Call cDocument :: OnNewDocument () call the application's deleteContents (); b. User code 3.4 call initialupdateFrame () Display Window 3.5 Returns the document pointer 4. Return

II. Open the document ON_COMMAND (ID_FILE_OPEN, CWINAPP :: OnfileOpen) Entrance: CWINAPP: ONFILEOPENCWINAPP to ONFILEOPEN's default implementation is called: cdocmanager :: onfileOpen () 1. Pop-up dialog allows users to select the file to be opened, return to the file Fully path name, use .2 .2 .2. Call the application's openDocumentfile (LPCTSTR LPSZFILENAME) 2.1 User Code 2.2 Call CWINAPP :: OpenDocumentFile (LpszFileName), call cdocmanager :: OpenDocumentFile a. Judging the open document without this file Object, there is an activation of the window and returns b. Call cmultidoCTemplate :: OpenDocumentFile () B.1 Create a new document object, create a new document object Corresponding sub-frame B.2 calling the application's onoPendocument () call cdocument : ONOPENDOCUMENT (). Open the file object. Call the application's deletedontents (); create the CARCHIVE object associated with this file object. Call the application document object's serialize () function. Close the CARCHIVE object, the file object (2) Show this file window B.3 returns

III. File Save ON_COMMAND (ID_FILE_SAVE, CDocument :: Onfilesave) Entry: CDocument :: OnfileSave () Call: cdocument :: DOFileSave () If the file name corresponding to the current document is empty or use null as a parameter call cDocument :: DOSAVE (NULL), otherwise, call cDocument :: DOSAVE (m_strpathname) with the file name corresponding to the current document;

ON_COMMAND (ID_FILE_SAVEAS, CDocument :: OnFileSaveAs) inlet: CDocument :: OnFileSaveAs () called with an argument to NULL directly 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 save dialog, set the name of the saved file, and return to the file. If lpszpahtname is not null, jump to the above steps, directly enter the next step 3. Call the application's onsavedocument () 3.1. User code 3.2. Call cDocument :: OnSaveDocument () a. Create or open the file object B. Create a corresponding CARCHIVE object c. Call the serialization function of the application document object Serialize () D Close the file object, the CARCHIVE object e. Setting the file unmodied flag 4. Return

转载请注明原文地址:https://www.9cbs.com/read-11545.html

New Post(0)