使用PreTranslateMessage可以实现 BOOL CXXXDlg::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class switch(pMsg->wParam) { case VK_LEFT: MessageBox("this is LEFT"); break; case VK_RIGHT: MessageBox("this is right"); break; case VK_UP: MessageBox("this is Up"); break; case VK_DOWN: MessageBox("this is Down"); break; default: break; } return CDialog::PreTranslateMessage(pMsg); }
BOOL CTest6Dlg::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if( pMsg->message == WM_KEYDOWN ) { if(pMsg->hwnd == GetDlgItem(IDC_EDIT1)->m_hWnd) { switch( pMsg->wParam ) { case VK_LEFT: AfxMessageBox("LEFT");
请问有什么其他的方法吗》
BOOL CXXXDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
switch(pMsg->wParam)
{
case VK_LEFT:
MessageBox("this is LEFT");
break;
case VK_RIGHT:
MessageBox("this is right");
break;
case VK_UP:
MessageBox("this is Up");
break;
case VK_DOWN:
MessageBox("this is Down");
break;
default:
break;
}
return CDialog::PreTranslateMessage(pMsg);
}
{
// TODO: Add your specialized code here and/or call the base class
if( pMsg->message == WM_KEYDOWN )
{
if(pMsg->hwnd == GetDlgItem(IDC_EDIT1)->m_hWnd)
{
switch( pMsg->wParam )
{
case VK_LEFT:
AfxMessageBox("LEFT");
//其他同理
}
}
return True;
}
return CDialog::PreTranslateMessage(pMsg);
}