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;
}
}
{
// TODO: Add your message handler code here and/or call default
switch(nChar)
{
case VK_ESCAPE: do something;
case .... :do other things;
}
}
PreTranslateMessage(MSG* pMsg)
中对pMsg->message=WM_KEYDOWN
时检查一下pMsg->wParam==VK_ESCAPE
或重载void OnCancel()函数就可以了:)
{
// 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);
}