在app类中重载PreTranslateMessage(MSG* pMsg);
重载后函数如下
BOOL CXXXXXApp::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)
{
return true;
}
if(pMsg->wParam == VK_RETURN)
{
::TranslateMessage(pMsg);
::DispatchMessage(pMsg);
return true;
}
}
return CWinApp::PreTranslateMessage(pMsg);
}