LRESULT CALLBACK KeyboardProc(int code, // hook code WPARAM wParam, // virtual-key code LPARAM lParam) // keystroke-message information { if (code == HC_ACTION) { // If this is a key up, or the Alt key is down, bail out now. if (!(lParam & 0xA0000000)) { if(::GetKeyState(VK_CONTROL) < 0)//Ctrl键按下 { if(wParam==0x31)//数字1 {
} } } } }
RegisterHotKey(m_hWnd,0xa101,MOD_CONTROL,VK_1); ...... BOOL MainDlg::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if (pMsg->message==WM_HOTKEY && pMsg->wParam==0Xa101) { //do Ctrl+1 Process } return CDialog::PreTranslateMessage(pMsg); } ...... UnregisterHotKey(this->m_hWnd,0xa101);
WPARAM wParam, // virtual-key code
LPARAM lParam) // keystroke-message information
{
if (code == HC_ACTION)
{
// If this is a key up, or the Alt key is down, bail out now.
if (!(lParam & 0xA0000000))
{
if(::GetKeyState(VK_CONTROL) < 0)//Ctrl键按下
{
if(wParam==0x31)//数字1
{
}
}
}
}
}
......
BOOL MainDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (pMsg->message==WM_HOTKEY && pMsg->wParam==0Xa101)
{
//do Ctrl+1 Process
}
return CDialog::PreTranslateMessage(pMsg);
}
......
UnregisterHotKey(this->m_hWnd,0xa101);