BOOL CWelcomeDlg::PreTranslateMessage(MSG* pMsg) //Called to filter messages before they are dispatched{ // TODO: Add your specialized code here and/or call the base class if(pMsg->message == WM_KEYDOWN && pMsg->wParam == 27) { CString s; s.Format("The wParam= %d The message = %d", pMsg->wParam, pMsg->message); MessageBox(s); return NULL; } return CDialog::PreTranslateMessage(pMsg);} 在消息调用之前的函数