BOOL CURLGatherApp::InitInstance()
{
// Standard initialization
// If you are not using these features and wish to reduce the size
//  of your final executable, you should remove from the following
//  the specific initialization routines you do not need. //CURLGatherDlg dlg;
CDlgConnToDB dlg;
CURLGatherDlg dlgMain;
dlg.m_pDlgMain = &dlgMain;

//m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
m_pMainWnd = &dlgMain;
int nMainResponse = dlgMain.DoModal();
if (nMainResponse == IDOK)
{
}
else
{
} // 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
m_pMainWnd = &dlgMain; } // Since the dialog has been closed, return FALSE so that we exit the
//  application, rather than start the application's message pump.
return FALSE;
}在CDlgConnToDB窗体上点取消后报错,不知道如何处理?

解决方案 »

  1.   

    dlg.m_pDlgMain = &dlgMain;
    ????else if (nResponse == IDCANCEL)
    {
    // TODO: Place code here to handle when the dialog is
    //  dismissed with Cancel
    m_pMainWnd = &dlgMain;   //??????????????
    }
      

  2.   

    m_pMainWnd = &dlgMain;   //??????????????
    这句话是没有的
      

  3.   

    CURLGatherDlg是主窗体
    CDlgConnToDB另外的窗体
      

  4.   

    dlg.m_pDlgMain = &dlgMain;
    ????????啥子东西哦
      

  5.   

    晕。这是设置CDlgConnToDB为主窗体
      

  6.   

    因为你点取消后执行m_pMainWnd = &dlgMain, 本应该响应CDlgConnToDB的事件,却响应了CURLGatherDlg, 导致了一些资源的错误操作 !
    我认为将m_pMainWnd = &dlgMain,mask 后就OK了 !
      

  7.   

    我认为将m_pMainWnd = &dlgMain,mask 后就OK了 !
    有道理,放到哪里比较合适?
      

  8.   

    也加一句int nMainResponse = dlgMain.DoModal();不就行了
      

  9.   

    也加一句int nMainResponse = dlgMain.DoModal();不就行了
    如果加上这句dlgMain这个窗体就显示出来了