- 作用
CWinApp类将封装应用程序的初始化
、运行
和终止
。基于框架生成的应用程序必须有且只有一个对象的类派生自 CWinApp,创建窗口之前需构造此对象。 - CWinApp类继承于CWinThread,它构成了应用程序的执行主线程。
class CWinApp : public CWinThread {
};
- CWinApp类的一些成员方法
- CWinApp方法调用顺序
- 代码断点调试熟悉调用流程
#include <afxwin.h>
class MyApp : public CWinApp{
virtual BOOL InitApplication(){
return CWinApp::InitApplication();
}
virtual BOOL InitInstance(){
CFrameWnd* pWnd = new CFrameWnd;
pWnd->Create(NULL, L"hello world");
pWnd->ShowWindow(SW_SHOW);
this->m_pMainWnd = pWnd;
return TRUE;
}
virtual int Run(){
return CWinApp::Run();
}
virtual BOOL OnIdle(LONG lCount){
return CWinApp::OnIdle(lCount);
}
virtual int ExitInstance(){
return CWinApp::ExitInstance();
}
};
MyApp theApp;