为什么在MFC程序代码中到不到Run()和ExitInstance()两个函数?
懂你得意思了,run()函数MFC里没有,功能类似的是InitInstance( )函数,工程创建的时候被自动创建在CxxxxApp类中,代码如下
BOOL CMy3DApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
CMy3DDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
ExitInstance()函数在工程创建的时候并没有创建,需要自己使用类向导创建在CxxxxAPP类中
创建后的代码为
int CMy3DApp::ExitInstance()
{
// TODO: Add your specialized code here and/or call the base class
return CWinApp::ExitInstance();
}
若满意请及时采纳,谢谢
MFC的运行机制不就是: InitInstance()——Run()——ExitInstance() 吗?怎么会没有呢?
你指的运行不是InitInstance()?app之后就是窗体的创建了,没有运行这个函数,创建窗体时有个InitDialog函数,你指的是它?它是创建窗体时首先要执行的函数