16,548
社区成员




BOOL CkeydemoDlg::PreTranslateMessage(MSG * pMsg)
{
if(WM_KEYDOWN == pMsg->message )
{
char nchar = pMsg->wParam;
BOOL bCtrl=::GetKeyState(VK_CONTROL)&0xF0000000;
BOOL bShift=::GetKeyState(VK_SHIFT)&0xF0000000;
BOOL bAlt=::GetKeyState(VK_MENU)&0xF0000000;
CString cszHotkey;
cszHotkey.Format(_T("%s%s%s%c"),bShift?_T("SHIFT + "):_T(""),
bCtrl?_T("CTRL +"):_T(""),bAlt ? _T("ALT + ") : _T(""),pMsg->wParam);
return true;
}
return false;
}
short int statusCtrl=GetKeyState(VK_CONTROL);
short int statusX =GetKeyState('X');
if((statusCtrl & 0x80) == 0x80 && (statusX & 0x80) == 0x80)
BOOL CADlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(WM_KEYDOWN == pMsg->message && _T('X') == pMsg->wParam)
{
if(GetKeyState(VK_CONTROL) < 0)
{
AfxMessageBox(_T("Ctrl+X"));
}
}
return CDialog::PreTranslateMessage(pMsg);
}