把OnCancel()(ON_COMMAND(IDCANCEL,OnCancel))重载掉,去掉对基类CDialog::OnCancel的调用。

解决方案 »

  1.   

    可以重载PreTranslateMessage函数将用户按esc键的消息截获,执行你想要用户在按esc是要执行的程序就可以了
      

  2.   

    BOOL CYourDlg::PreTanslateMessage(LPMSG pMsg)
    {
      if((pMsg->message==WM_KEYDOWN ||pMsg->message==WM_KEYIP) 77 pMsg->wparam==VK_ESCAPE)
        {
            //to do your thing
        return FALSE;
        }
      return   CBaseDlg::PreTranslateMessage(pMsg);
    }
      

  3.   

    你说的对话框是指MessageBox生成的呢,还是CDialog类啊。