The macro framework system of MFC:
MFC is a C ++ class library. programmers use, inherit, and extend appropriate classes to achieve specific purposes.
CWinApp-> CTapp, CDocument-> CTDoc, CView-> CTView, CMDIFrameWnd-> CMainFrame, CMDIChildWnd-> CChildFrame
Application object, Document Object, view object, main frame window object (window port, toolbar and status bar) and document border window object.
File pre-Compilation: Pre-Compilation of some of the MFC standard header files used in the Project. Later, the pre-compilation results will not be compiled. The pre-compiled header file is generated by compiling stdafx. cpp and named after the project name.
The compiler thinks, so in the instruction # include "stdafx. h "the previous code is pre-compiled, and it skips # include" stdafx. h "command, using projectname. pch compiles all the code after this command.
Differences between MFC Object and Windows Object:
Data structure:
An MFC Object is an instance of the corresponding C ++ class (defined by an MFC or Programmer). A Windows Object is the internal structure of a Windows system and is referenced by a handle;
MFC defines a member variable for the class to save the Windows Object handle corresponding to the MFC Object.
Level:
MFC objects are high-level, while Windows objects are low. MFC objects encapsulate most or all of the functions of Windows objects. Users of MFC objects do not need to directly use Windows Object HANDLE to use Win32 APIs, instead, it refers to the member functions that reference the corresponding MFC Object.
Create:
The MFC Object is directly created by the program through the constructor; the Windows Object is created by the corresponding SDK function.
First, create an MFC Object, create it in the STACK, or create it in the HEAP. The MFC Object handle instance variable is empty or not a valid handle. Then, call the MFC Object member function to create the corresponding Windows Object. The MFC handle variable stores a valid handle.
Conversion:
Scope of use:
The MFC Object is invisible and unavailable to other processes of the system. Once a Windows Object is created, its handle is global throughout the Windows system. Typical: A process can obtain the window handle of another process and send messages to the window. For the thread of the same process, only the MFC Object created by this thread can be used, and the MFC Object of other threads cannot be used.
Destruction:
The MFC Object disappears with the calling of the destructor, but the Windows Object must be destroyed by the corresponding Windows system function. The devices in the device description table have different CDC objects. The corresponding HDC handle objects may not be destroyed but released.
Windows Object
Common rules for compiling Windows applications using SDK Win32 APIs:
Compile the WinMain function-compile the WndProc Window for message and event processing, Register the Window (Register Window) in WinMain, create the Window, and then start the message loop of the application.
From: column of landy_mo