code_junkie

Control for getting hotkeys like tab and space

Nov 11th, 2011
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. LRESULT CALLBACK MessageHook(int code, WPARAM wParam, LPMSG lpMsg)
  2. {
  3. LRESULT lResult = 0;
  4.  
  5. if ((code >= 0) && (code == MSGF_DIALOGBOX))
  6. {
  7. if (lpMsg->message == WM_KEYDOWN)
  8. {
  9. //-- process the key down message
  10. lResult = 1;
  11. }
  12. }
  13.  
  14. // do default processing if required
  15. if (lResult == 0)
  16. {
  17. lResult = CallNextHookEx(MessageFilterHook, code, wParam, (LPARAM)lpMsg);
  18. }
  19.  
  20. return lResult;
  21. }
  22.  
  23. //-- create an instance thunk for our hook callback
  24. FARPROC FilterProc = (FARPROC) MakeProcInstance((HOOKPROC)(MessageHook),
  25. hInstance);
  26. //-- attach the message hook
  27. FilterHook = SetWindowsHookEx(WH_MSGFILTER,
  28. (HOOKPROC)FilterProc,
  29. hInstance, GetCurrentThreadId());
  30.  
  31. //-- remove a message hook
  32. UnhookWindowsHookEx(MessageFilterHook);
Add Comment
Please, Sign In to add comment