Analysis of mfc operating principle

Analysis of MFC operating principle:

Hello everyone, here is Shi Kankan’s blog. This article introduces my understanding of MFC operating principle

Many people were distressed because they could not find the main function when they first started contacting MFC. I checked some information about this

................................................. ...Updated on 2018.27 ... ................................................. ........................

First define theApp and then call the constructor (constructing the subclass first constructs the parent class, constructing the parent class will complete some initialization work), and then call _tWinMain (_tWinMain is defined in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\ atlmfc\src\mfc\appmodul.cpp) ;_tWinMain calls AfxWinMain (defined in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\mfc\winmain.cpp); AfxWinMain calls InitInstance:! pThread->InitInstance() (based on the principle of virtual function calls the subclass InitInstance: ); register to LoadFream to generate the display update window and then call nReturnCode = pThread->Run(); enter the message loop (C:\Program Files (x86) )\Microsoft Visual Studio 10.0\VC\atlmfc\src\mfc\thrdcore.cpp CWinThread::Run) inside is a for, while, do loop (the update window also has a message loop)


initialize the global object and enter the winmain registration window generating window display window message loop update
message mapping: by the handle pointer found
   


here similar to the global object theapp a global variable a




#include <, iostream.h>
int. 6 = a;
int main ()
{
COUT << endl << a ;
}


6 is output here, because a has been initialized before the main function is called (only global variables); theapp is the same

Guess you like

Origin blog.csdn.net/zxpcus/article/details/79672496