主程序是基于对话框类的.外加了一个用户登录的对话框.在主程序中调用如下
BOOL CPIMS_1App::InitInstance()
{
AfxEnableControlContainer();
         ..........
CLoginDlg logdlg;
    
if(logdlg.DoModal()==IDCANCEL)
{
    
    return false;
}
         ....
}
登录对话框中的Oncancel()相应Cancel按键如下
void CLoginDlg::OnCancel() 
{
MessageBox("系统退出!","登录提示",MB_OK);
AfxGetMainWnd()->PostMessage(WM_QUIT);

CDialog::OnCancel();
}
可是在调试运行按下Cancel按键退出系统时总是有错误的声音,但没有提示信息.
设置断点,发现深入到MFC\SRC\AFXSTATE.cpp文件中时会有Unhandled exception in PIMS.exe(KERNEL32.DLL)0XE06D7363:Microsoft C++ Exception. 提示
这是什么问题呢?

解决方案 »

  1.   

    AfxGetMainWnd()->PostMessage(WM_QUIT);这句有什么用,都已经在退出过程中了,还发送WM_QUIT消息干嘛?
      

  2.   

    如果去掉AfxGetMainWnd()->PostMessage(WM_QUIT)
    void CLoginDlg::OnCancel() 
    {
    MessageBox("系统退出!","登录提示",MB_OK);
    //AfxGetMainWnd()->PostMessage(WM_QUIT);CDialog::OnCancel();
    }
    退出时错误提示:Run time erro!This application has requested the runtime to terminate it in an unusual way.