我新建了一个对话框类,是用来进入主对话框前输入用户姓名和密码信息的,要使在单击了Cancel以后,就退出整个程序,应该如何实现?
谢谢指教!

解决方案 »

  1.   

    BOOL CMatMISClientApp::InitInstance()
    {
    CXXDlg dlg;
    if(IDCANCEL == dlg.DomModal())
    return FALSE;
    }
      

  2.   


    CXXDlg dlg;//输入用户名和密码的对话框
    if(IDCANCEL == dlg.DomModal())
    return FALSE;
    加在
    C***Dlg dlg;
    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
    }
    之前
      

  3.   

    在APP的文件里,在调用主窗口之前添加你那个新对话框的代码,判断如果返回值为IDCANCEL则不调用主窗口即可
      

  4.   

    可以为cancel按钮添加事件,在事件代码当中发送PostQuitMessage