/* Windows NT 4.0 Service Pack 3 and Later and Windows 2000 Applications can disable ALT+TAB or CTRL+ESC by installing a low-level keyboard hook. A low-level keyboard hook (WH_KEYBOARD_LL) is installed by calling SetWindowsHookEx. For more information on Window hooks see the "Hooks" overview in the Platform SDK documentation.The following is a sample low-level keyboard hook procedure that disables CTRL+ESC, ALT+TAB, and ALT+ESC: */ LRESULT CALLBACK LowLevelKeyboardProc (INT nCode, WPARAM wParam, LPARAM lParam) { // By returning a non-zero value from the hook procedure, the // message does not get passed to the target window KBDLLHOOKSTRUCT *pkbhs = (KBDLLHOOKSTRUCT *) lParam; BOOL bControlKeyDown = 0;switch (nCode) { case HC_ACTION: { // Check to see if the CTRL key is pressed bControlKeyDown = GetAsyncKeyState (VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1);// Disable CTRL+ESC if (pkbhs->vkCode == VK_ESCAPE && bControlKeyDown) return 1;// Disable ALT+TAB if (pkbhs->vkCode == VK_TAB && pkbhs->flags & LLKHF_ALTDOWN) return 1;// Disable ALT+ESC if (pkbhs->vkCode == VK_ESCAPE && pkbhs->flags & LLKHF_ALTDOWN) return 1;break; }default: break; } return CallNextHookEx (hHook, nCode, wParam, lParam); }
{ if (pMsg->message == WM_KEYDOWN)
{
if(pMsg->wParam == VK_ESCAPE)//加上CTRL键按下判断即可
{
return TRUE;
}
}
return CDialog::PreTranslateMessage(pMsg);
}如果要在整个程序或者系统中屏蔽,可以使用键盘钩子进行屏蔽。
如果是好多程序的话就得一个一个添了
http://topic.csdn.net/t/20020610/10/791067.html
{ if(pMsg->wParam == VK_ESCAPE && pMsg->wParam == VK_CONTROL)
return TRUE; } 但是没有屏蔽掉啊。请问是哪里出问题了?
{
if(GetKeyState(VK_ESCAPE) < 0 && GetKeyState(VK_CONTROL) < 0)
{
AfxMessageBox(_T("CTRL + ESC"));
return TRUE;
}
}this? 你不是要屏蔽键盘上的Ctrl+ESC组合键 ?
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) 中添加的、。
http://www.vckbase.com/document/viewdoc/?id=424
/*
Windows NT 4.0 Service Pack 3 and Later and Windows 2000
Applications can disable ALT+TAB or CTRL+ESC by installing a low-level keyboard hook. A low-level keyboard hook (WH_KEYBOARD_LL) is installed by calling SetWindowsHookEx. For more information on Window hooks see the "Hooks" overview in the Platform SDK documentation.The following is a sample low-level keyboard hook procedure that disables CTRL+ESC, ALT+TAB, and ALT+ESC:
*/
LRESULT CALLBACK LowLevelKeyboardProc (INT nCode, WPARAM wParam, LPARAM lParam)
{
// By returning a non-zero value from the hook procedure, the
// message does not get passed to the target window
KBDLLHOOKSTRUCT *pkbhs = (KBDLLHOOKSTRUCT *) lParam;
BOOL bControlKeyDown = 0;switch (nCode)
{
case HC_ACTION:
{
// Check to see if the CTRL key is pressed
bControlKeyDown = GetAsyncKeyState (VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1);// Disable CTRL+ESC
if (pkbhs->vkCode == VK_ESCAPE && bControlKeyDown)
return 1;// Disable ALT+TAB
if (pkbhs->vkCode == VK_TAB && pkbhs->flags & LLKHF_ALTDOWN)
return 1;// Disable ALT+ESC
if (pkbhs->vkCode == VK_ESCAPE && pkbhs->flags & LLKHF_ALTDOWN)
return 1;break;
}default:
break;
}
return CallNextHookEx (hHook, nCode, wParam, lParam);
}