MFC's
Live:
AfxWinMain()%1 //有My表示是自己的类
CWinApp * pApp=AfxGetApp();
AfxWinInit(...);
pApp->InitApplication();
pApp->InitInstance();★//CWinApp的虚函数,你可以在这里对应用程序启动(如打开文件等)修改,CMyWinApp里重载
| CMY_WinApp::InitInstance()
| | m_pMainWnd=new CMyFrameWnd[MainFrame]();
| | CMyFrameWnd::CMyFrameWnd() //construct
| | Create(NULL,..."MainMenu"...);
| | | CWnd::CreatEx(...)
| | | | CREATESTUCT cs;
| | | | cs初始化
| | | | CMyFrameWnd::PreCreateWindos(cs);//★CWnd的虚函数,你可以在这里对窗口类做修改,CMainFrame里重载
| | | | | CFrameWnd::PreCreateWindow(cs);//你可以用GetClassInfo(api func)获得副本进行修改
| | | | | | AfxDeferRegisterClass(AFX_WNDFRAMEORVIEW);//是个宏扩展如下
| | | | | | AfxRegisteredClasses(对系统已注册的窗口类)? TRUE : AfxDeferRegisterClass(对系统未注册的窗口类)
| | | | | | wndcls.lpfnWndProc=DefWindowProc();_______________________^
| | | | | | wndcls.hInstance=AfxGetInstanceHandle();
| | | | | | wndcls.hCursor=afxData.hcurArrow;
| | | | | | AFX_MODULE_STATE * pModuleState=AfxGetModuleState();
| | | | | | //根据不同窗口类进行处理 见《深入浅出mfc》P286
| | | | | | AfxRegisterClass()//真正注册窗口
| | | | AfxHookWindowCreate(this);//把窗口类的窗口函数DefWindowProc改换为AfxWndProc
| | | | | ::SetWindowsHookEx(WH_CBT,_AfxCbtFilterHook,.....);//过滤ACTIVE,CREATEWND,DESTROYWND,MINMAX...
| | | | | | _AfxStandardSubclass()
| | | | | | oldWdProc=(WNDPROC)SetWindowLong(hWnd,GWL_WNDPROC,(DWORD)AfxGetAfxWndProc();
| | | | | | return &AfxWndProc//!!!!!!!!!!!!!!!!!!!!!!!!____________^
| | | | ::CreatWindowEx(cs.dwExStyle.....)//触发WM_CREATE消息 ★重载OnCreat挂接toolbar statubar等
| m_pMainWnd->ShowWindow(m_nCmdShow); //将窗口显示出来
| m_pMainWnd->UpdateWindow(); //发送WM_PAINT消息
nReturnCode=pApp->Run(); //开始消息循环处理
| CWinApp::Run()
| | do{//以下包含在pumpmessage()中
| | ::GetMessage(&msg,...); //从系统消息对列获取消息
| | PreTranslateMessage(&msg);
| | ::TranslateMessage(&msg); //将虚拟键转换为字符消息并送到应用程序队列
| | ::DispatchMessage(&msg); //把&msg所指象的消息传送到指定窗口(CMainFrame)的窗口函数
| | (DefWnidowProc(wndcls.lpfnWndProc)----(use subclass-hook)---->AfxWndProc是全局的函数)
| }while(::PeekMessage(&msg)); //取消息不同与getmessage的是不等待就返回
AfxWinTerm();
Dided
--------------------next---------------------
阅读(360) | 评论(0) | 转发(0) |