Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LRESULT CALLBACK MessageHook(int code, WPARAM wParam, LPMSG lpMsg)
- {
- LRESULT lResult = 0;
- if ((code >= 0) && (code == MSGF_DIALOGBOX))
- {
- if (lpMsg->message == WM_KEYDOWN)
- {
- //-- process the key down message
- lResult = 1;
- }
- }
- // do default processing if required
- if (lResult == 0)
- {
- lResult = CallNextHookEx(MessageFilterHook, code, wParam, (LPARAM)lpMsg);
- }
- return lResult;
- }
- //-- create an instance thunk for our hook callback
- FARPROC FilterProc = (FARPROC) MakeProcInstance((HOOKPROC)(MessageHook),
- hInstance);
- //-- attach the message hook
- FilterHook = SetWindowsHookEx(WH_MSGFILTER,
- (HOOKPROC)FilterProc,
- hInstance, GetCurrentThreadId());
- //-- remove a message hook
- UnhookWindowsHookEx(MessageFilterHook);
Add Comment
Please, Sign In to add comment