在PretranslateMessage里面判断,如果单独判断是否按下了C键问题,但同时按下ALT+C时为可没有进入?
if(pMsg-> message == WM_KEYDOWN)
{
if (pMsg-> wParam == 'C' )
{ //同时按下却执行不到这里。
if(::GetKeyState(VK_MENU)&0x8000)
AfxMessageBox( "ALT+C");
}
}
那判断按下了ALT+C的正确方式是什么?
if(pMsg-> message == WM_KEYDOWN)
{
if (pMsg-> wParam == 'C' )
{ //同时按下却执行不到这里。
if(::GetKeyState(VK_MENU)&0x8000)
AfxMessageBox( "ALT+C");
}
}
那判断按下了ALT+C的正确方式是什么?
{
if(pMsg-> message == WM_KEYDOWN)
{
if(pMsg->wParam == 'C' || pMsg->wParam == 'c')
{
//用 GetKeyState 来查看按键是否按下
if((GetKeyState(VK_ALT))
//..............
}
}
return CMyCtrl::PreTranslateMessage(pMsg);
}
另外 if (pMsg-> wParam == 'C' ) 这句,不应该等于‘C’,应该是c的键码
BOOL CXXDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(HIBYTE(::GetKeyState(VK_MENU)) && WM_SYSKEYDOWN == pMsg->message && _T('C') == pMsg->wParam)
{
AfxMessageBox("OK");
} return CDialog::PreTranslateMessage(pMsg);
}