void CGame2View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
// TODO: Add your message handler code here and/or call default
switch(nChar)
{
case VK_ESCAPE: do something;
         case .... :do other things;
         }
}
         

解决方案 »

  1.   

    你要看你的程序是什么类型的,如果是对话框的,那就只能在
    PreTranslateMessage(MSG* pMsg) 
    中对pMsg->message=WM_KEYDOWN
    时检查一下pMsg->wParam==VK_ESCAPE
    或重载void OnCancel()函数就可以了:)
      

  2.   

    BOOL CHcybdcDlg::PreTranslateMessage(MSG* pMsg) 
    {
    // TODO: Add your specialized code here and/or call the base class
             if(pMsg->message == WM_KEYDOWN)
      if(pMsg->wParam == VK_ESCAPE)
                 if(MessageBox("ESC键","",MB_YESNO|MB_ICONQUESTION ) == IDYES){
                      //dosomething
    return TRUE;
                    }

                    
    return CDialog::PreTranslateMessage(pMsg);
    }
      

  3.   

    http://www.csdn.net/develop/read_article.asp?id=7708