CDlgJob退出了,实例也不在了,CDlgOpenLot OpenLotDlg;会做为一个顶级窗口显示出来,不过这么写可能会出错,因为OpenLotDlg已经释放了。

解决方案 »

  1.   

    在 OnCancel();后面加个断点debug一下,看看代码是怎么走的
      

  2.   

    CDialog::OnCancel只调用CDialog::EndDialog关闭对话框;     
    OnClose()是响应   WM_CLOSE   的.一定程度上可以说CDialog::EndDialog()和OnClose()完成类似的工作,但处理的机制不一样,前者是CDialog的对象机制,后者是WM的消息映射机制。所以你OnCancel只是关闭了你之前的对话框,然后又模态的显示了另一个对话框,当这个对话框关闭后,系统才会调用进行销毁工作
      

  3.   

    对话框已经不显示了,但对话框还没有退出:
    程序在app中等主对话框退出:
    m_pMainWnd = &dlg;
    int nResponse = dlg.DoModal();
    if (nResponse == IDOK)
      

  4.   

    断点进入OnCancel可发现在OnCancel();内部调用的是::EndDialog(m_hWnd, nResult);再看MSDN上对EndDialog的说明:EndDialog does not destroy the dialog box immediately. Instead, it sets a flag and allows the dialog box procedure to return control to the system. The system checks the flag before attempting to retrieve the next message from the application queue. If the flag is set, the system ends the message loop, destroys the dialog box, and uses the value in nResult as the return value from the function that created the dialog box. 
    因此可以猜出原因应该就在这里。