侯老先生的大作中提到:
第一步:CSocketClinetApp theApp; 此处请打断点。
theApp配置完成后(哈哈,这部分还是值得一看的,小弟学了不少),WinMain登场,MFC准备好由连接器直接加入应用程序代码中,
第二步:即_tWinMain,该函数"_t"是为了支持Unicode而准备的一个宏。
也许是本人笨拙,只找到了如下方法找到MFC的Main函数查看运行过程(VC6.0):
方法:debug->Restart(Ctrl+shit+F5)->进入:
_tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstan、ce,
LPTSTR lpCmdLine, int nCmdShow)
{
// call shared/exported WinMain
return AfxWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow); //此处打断点,方便以后调试 XX
} //第六步:重回主函数,完成主函数的作用
Restart便进入此处{,F10后到return...语句处,之后F11进入int AFXAPI AfxWinMain....
int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow)
{
//.............................
CWinApp* pApp = AfxGetApp();
//.............................
// Perform specific initializations
if (!pThread->InitInstance())
{
if (pThread->m_pMainWnd != NULL) //第三步:断点到此
{
TRACE0("Warning: Destroying non-NULL m_pMainWnd\n");
pThread->m_pMainWnd->DestroyWindow();
}
nReturnCode = pThread->ExitInstance(); //第五步:等到你程序退出时至此
goto InitFailure;
}
nReturnCode = pThread->Run();
//........................
}
第三步运行后,由于CWinThread* pThread = AfxGetThread();你自己写的程序中重载了,因此会跳转到:
BOOL CSocketClinetApp::InitInstance() //也就是第一步:CSocketClinetApp theApp;下面的内容
{
//.............
CSocketClinetDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal(); //第四步:这里面该干嘛的顺序想必大家都看懂了,不解释
}
接下来侯大师《深入浅出MFC》第三篇P276页就已经写得很清楚啦,小弟大致看懂。
很无奈,这种方法只适用VC6.0,我常用的VS2008不知道该如何做,希望高手帮忙。