programming+windows+MFC

1)CMyApp declares no data members

2)CWinApp::InitInstance run after application build but before the window is create

 2.1 InitInstance is the perfect place to perform initializations that need to be done each time the program starts(Just like VB's formload?)

  2.2m_pMainWnd = new CMainWindow; (in InitInstance ):constructs a CMainWindow object and copies its address to the application object's m_pMainWnd data member

2.3 a window is not initially visible unless it is created with a WS_VISIBLE
attribute—by calling ShowWindow and UpdateWindow through the CMainWindow pointer:

(ShowWindow and UpdateWindow are CWnd member functions common to all window objects)

2.4can use ExitInstance to clean up when an application terminates

3)onldle un exitinstancepretranslatemessage

4)Right after starting, AfxWinMain calls a function named AfxWinInit to initialize the framework and copy hInstance, nCmdShow,and other AfxWinMain function parameters to data members of the application object.

Then it calls InitApplication andInitInstance 

5)An MFC application creates a window by creating a window object and calling its Create or CreateEx function. Hello creates a CMainWindow object in CMyApp::InitInstance. CMainWindow's constructor creates the window you see on the screen:

原文地址:https://www.cnblogs.com/gosteps/p/3317732.html