VC application framework

zhaozj2021-02-16  136

VC Application Framework VC Application Framework provides great feature for our development, using it easy to generate an application framework. Many common features, such as documentation, open, save Most of the code for operation is done by the application framework. These operations are transparent to users of 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) Entrance: cdocument :: onfilesaves () Take NULL to Parameter Direct calls CDocument :: DOSAVE (NULL); CDocument :: DOSAVE (LPCTSTR LPSZPATHNAME, BOOL BREPLACE); if lpszpathname is null, 1. Set the application default file name 2. Open Universal File Save Dialog, and save the file by the user Name, and return to this file name If lpszpahtname is not null, jump to two steps, go directly into the next step 3. Call the application's onsavedocument () 3.1. User code 3.2. Call cDocument :: OnsaveDocument () A. Created Or open the file object B. Establish a corresponding CARCHIVE object c. Call the serialization function serialize () d. Close the file object, CARCHIVE object e. Settings file unmodied flag 4. Return

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

New Post(0)