Use the wh_keyboard_ll type hook method in the Dialog program:
Setwindowshookex (WH_KEYBOARD_LL, (HookProc) LowlevelKeyboardProc, AFXGetApp () -> M_HINSTANCE, NULL);
Lresult Callback LowlevelKeyboardProc (int Ncode, WPARAM WPARAM, LPARAM LPARAM) {// by return a non-Zero Value from the hook procedure, the // message does not get passed to the Target window
KbdllHookStruct * pkbhook = (kbdllhookstruct *) lparam; bool bcontrolKeydown = 0;
Switch (ncode) {case hc_action: {// check to see et {// check to see, {// chey ispessed 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;
// Response to Up if ((pkbhs-> vkcode == vk_up) && (wm_keyup == wparam) {hwnd hwnd = :: FindWindow (Null, "Windowcaption"); :: PostMessage (hwnd, wm_command, id_menu_item, 0L );};} Return CallNexthookex (null, ncode, wparam, lparam);
Bool installkbhook () {
IF (hHOOKKB) Uninstallkbhook ();
HHOOKKB = SETWINDOWSHOKEX (WH_KEYBOARD_LL, (HOOKPROC) LowlevelKeyboardProc, AFXGetApp () -> M_HINSTANCE, NULL);
Return (hHOOKKB! = NULL);
}
BOOL Uninstallkbhook () {
Bool fok = false; if (hHOOKKB) {fok = unhookwindowshookex (hHOOKKB); hHOOKKB = NULL;} return (fok);