Also said that the header file MFC program generally needs to load the header file and its role: stdafx.h: This file is used as the Precompiled Header file, which is just loaded into other MFC header files to improve compilation efficiency. AFXWIN.H: The Windows MFC header file must be loaded, declare all MFC classes, indirectly loaded Windows.h. AFXEXT.H: Toolbar, Status Bar. AFXDLGS.H: Common Dialog. AFXCMN.H: Common Control. AFXCOLL.H: Collectes classes. AFXDLLX.H: MFC Extension DLLS. AFXRES.H: The RC file must be loaded, and the ID of the standard resource is declared. Windows SDK's header file Windows.h, commandlg.h, Toolhelp.h, DDEML.H is already as foresee.
The MFC program process The WIN32 program process has been confident. Now, the MFC program in the most common DOCTEMPLATE / Document / View / Frame format (indicated by CMYXXX in CMYXXX), to facilitate the original code, HEHE: 1) Global object THEAPP (CMYWINAPP), before WinMain (nonsense, he is a global ..); 2) WinMain (): adds to code from the pre-compiler (in AppModul.cpp), by him callswinmain () (in WinMain.cpp); 3) AFXWINMAIN (), in turn, AFXWININIT () (in AFXWIN.INL), cwinapp :: initApplication () (in Appcore.cpp), CMYWINAPP :: InitInstance () (overload), CWINAPP: : Run () (in appcore.cpp), the effect is as follows; 4) AFXWininit (): AFX internal initialization operation, such as generating a pointer PAPP, get a handle, initial thread, setting Windows Hook, etc. 5) CWINAPP :: initApplication : Initialization Process (?), Set CDOCMANAGER (I know it according to I know, in Serialize); 6) CMYWINAPP :: InitInstance (): New / Add CDOCTemplate object, Planning DOC, View, Frame Relationship, window display, detail after detail; 7) cwinapp :: run (): Message mechanism, constantly loop, call cwinthread :: run () (in thrdcore.cpp); 8) cwinthread :: run () Call pumpMressage () (in thrdcore.cpp); 9) PumpMressage () is different from Win32, and the detailed message mechanism is followed. 10) Enabling the WM_QUIT end process.
Take the aforementioned CMYWINAPP :: InitInstance () (overload) process: 1) New CMYMDIFRAME object, the most main window object; 2) call cframeWnd :: loadFrame () (in winfrm.cpp), generate the main window and add menu, etc. And specify the window title, file title, file extension name, etc. (IDR_MAINFRAME, IN RC file); 3) loadFrame () internal registration window class, call cframeWnd :: Create () (in winfrm.cpp), cframewnd :: Create ) call CWnd :: CreateEx (in WINCORE.CPP), CWnd :: CreateEx call CMDIFrameWnd :: PreCreateWindow () (WINMDI.CPP), CMDIFrameWnd :: PreCreateWindow () to return to the CWnd :: CreateEx, CWnd :: CreateEx call :: CREATEWINDOWEX (), triggered WM_CREATE, was found by cframewnd :: oncreate (winfrm.cpp) (the fake process is a post-wrap); 4) cframeWnd :: oncreate call cframeWnd :: OnCreateHelper (Winfrm.cpp); Call cframeWnd :: OnCreateClient (winfrm.cpp); The latter calls cframeWnd :: CreateView (winfrm.cpp); 5) View is dynamically created, the Windows window is generated. 6) Back to InitInstance, showwindows (), UpdateWindows (); connected to 7) The above focus on CView and CFRAM .. generation, toolbar, and status bar, etc., will also be generated after WM_CREATE, not described. MFC Program - Document / View Supported Window Program Principle (OK, HEHE) CDOCTemplate Object: Pointing Doc / View / Frame Housekeeper, derived two subclasses CMUTIDEMPLATE and CSINGLEDOCTEMPLATE (see if it is a bit like MDI and SDI) , Generally, the program can handle multiple data file types, you must have multiple cdoctemplates, which are not related to SDI, MDI, only open a point in SDI, but he can still support multiple data types; CDOC ..: Carrying data, responsible for reading and writing, is of course serialize (); cView: presentation data, used to display, onDraw doesn't have to say it! Cframe ..: View is a window without a border, is realized in the outer frame of its periphery. This is Frame, he is independent from CView, specifically responsible for the user interface, Microsoft should specifically isolate the UI management machine, we There is no way, huh, huh!