InInitInstance函数里, 只有当DoModal返回的时候,才会执行 InitInstance里函数里的 最后一句return FALSE. 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; //即 只有DoModal返回后, 这一句代码才能执行。而这一句代码影响到AfxWinMain里的代码.}然后才进入以下代码:
// 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();(内部有消息循环)有人指出 我的理解不对, pThread->Run 可以在 pThread->InitInstance()没执行完毕 就可以开始执行了。 这是怎么回事???
原帖子: http://bbs.csdn.net/topics/390359424
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; //即 只有DoModal返回后, 这一句代码才能执行。而这一句代码影响到AfxWinMain里的代码.}然后才进入以下代码:
// 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();(内部有消息循环)有人指出 我的理解不对, pThread->Run 可以在 pThread->InitInstance()没执行完毕 就可以开始执行了。 这是怎么回事???
原帖子: http://bbs.csdn.net/topics/390359424
RETURN FALSE 就是为了不让pThread->Run 开始。
以后 在加入dlg::mousemove 就可以响应了应该是运行run!
还有请看 原帖子: http://bbs.csdn.net/topics/390359424
我只是说没有运行pThread->Run,并没有说没有运行runmodalloop。
pThread->Run是线程的消息循环,runmodalloop是对话框的消息循环,
楼主不要搞混了。
都回答的很清楚了,没用运行pThread->Run!
你的意思是 对话框自身的收到了wm_quit,所以导致
messagbox没有弹出来????
附上我的一篇关于消息循环的理解。