运行对话框程序,直接跳到这一步。
心都凉了,辛辛苦苦地弄了半天,居然运行不了
if (!pThread->InitInstance())
{
if (pThread->m_pMainWnd != NULL)
{
TRACE(traceAppMsg, 0, "Warning: Destroying non-NULL m_pMainWnd\n");
pThread->m_pMainWnd->DestroyWindow();
}
nReturnCode = pThread->ExitInstance();
goto InitFailure;
}
nReturnCode = pThread->Run();
耐心单步调试了一下。在InitInstance函数中,dlg.DoModal()失败了。
m_pMainWnd = &dlg;
INT_PTR 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
}
原来是我把对话框的style 从“popup”改成“child”了,改回来就可以运行了。
网上的情况一般是你从别的地方拷贝过来的程序,缺少某些资源ID