我认为因为
int nResponse = dlg.DoModal();
    if (nResponse == IDOK)
其中的IDOK事实上就响应了关闭这个程序的消息了,那么你就不可能再调用另一个窗口,你如果自己弄一个BUTTON,我想就不会这样子了

解决方案 »

  1.   

    把这两句
    SecDlg dd;
    nResponse = dd.DoModal();  
    加在OnOK()中
    肯定行
      

  2.   

    哪我要先关掉以前的对话框才行,怎么关呢showwindows(hide)
      

  3.   

    把这3句
            delete this;
            SecDlg dd;
            nResponse = dd.DoModal();  
    加在OnOK()中
      

  4.   

    CMainDlg dlg;
    m_pMainWnd = &dlg;
    int nResponse = dlg.DoModal();
    if (dlg.DoModal == IDOK)
    {
    SecDlg dd;
    dd.DoModal();  //返回 -1
    }
    else 
    {
    // TODO: Place code here to handle when the dialog is
    //  dismissed with Cancel
    }
    return FALSE;
    }
    email: [email protected]
      

  5.   

    在InitInstance里这样做肯定不行,
      

  6.   

    啊,错了:sorry
    应该是:
             CMainDlg dlg;
    m_pMainWnd = &dlg;
    if (dlg.DoModal() == IDOK)//直接调用
    {
    SecDlg dd;
    dd.DoModal();  //返回 -1
    }
    else 
    {
    // TODO: Place code here to handle when the g is
    }
    return FALSE;
    }
      

  7.   

    找到了解决方法了:
    在显示第二个窗口前,消息队列里还压着一个WM_QUIT。把它扔掉第二个对话框就出来了。
    CMyApp::InitInstance()
    {
       CMainDlg dlg;
        m_pMainWnd = &dlg;
        int nResponse = dlg.DoModal();
        if (nResponse == IDOK)
        {
      MSG msg;
    while( PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE) );
           SecDlg dd;
            m_pMainWnd = ⅆ           //这个是必须的
            nResponse = dd.DoModal(); 
        }
        else if (nResponse == IDCANCEL)
        {
            // TODO: Place code here to handle when the dialog is
            //  dismissed with Cancel
        }
        return FALSE;
    }