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

解决方案 »

  1.   

    >>pThread->Run 可以在  pThread->InitInstance()没执行完毕 就可以开始执行了。不可能,谁说都是忽悠你。
    RETURN FALSE 就是为了不让pThread->Run 开始。
      

  2.   

    执行到 INT_PTR nResponse = dlg.DoModal();
    以后 在加入dlg::mousemove 就可以响应了应该是运行run!
      

  3.   

    你的解释,不对吧,  你用sdk写一个模式对话框工程,没有消息循环也是可以的,因为模式对话框本身就可以接受消息。
    还有请看 原帖子: http://bbs.csdn.net/topics/390359424
      

  4.   

    pThread->Run和对话框的runmodalloop能一样么?
    我只是说没有运行pThread->Run,并没有说没有运行runmodalloop。
    pThread->Run是线程的消息循环,runmodalloop是对话框的消息循环,
    楼主不要搞混了。
      

  5.   

    你说的那个帖子我也看了。
    都回答的很清楚了,没用运行pThread->Run!
      

  6.   


    你的意思是 对话框自身的收到了wm_quit,所以导致
    messagbox没有弹出来????
      

  7.   

    http://blog.csdn.net/zhoujielunzhimi/article/details/8548669
    附上我的一篇关于消息循环的理解。