In the past few days I have one question:
In MFC, we create an application object derived from CWinApp. We create this object globally. So the MFC framework will use this object to start the application.
But I don’t know how the frame work comes to know about my global object.
Please explain me the internal mechanism whereby MFC learns about the application object.
After debugging the sample MFC application I learned how the framework knows about the application object.
The application object is global and inherited from
CWinApp. Since the object is global this object is constructed beforeWinMainis called. While constructing the derived object theCWinAppclass constructer is called; at this time framework captures the handle:The above line is copied from the MFC
CWinApp::CWinApp(LPCTSTR lpszAppName)constructor.If you want further details then go to the definition and declaration of the class
CWinApp.