intercepting WM_CHAR message
-
im trying to get the WM_CHAR message and this set up is not doing it. i have an edit text box in my window and all im getting is the keydown message when i type to it.
LRESULT CALLBACK GetMsgProc(int code, WPARAM wParam, LPARAM lParam){ if(code == HC_ACTION){ MSG* pMsg = (MSG*)lParam; if(pMsg->message == WM_CHAR){ int i=0; i = i +10;//test for WM_CHAR breakpoint } } return CallNextHookEx(g_KeybdHook, code, wParam, lParam); }
hook in main:g_KeybdHook = SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, 0,GetCurrentThreadId());
thanks -
im trying to get the WM_CHAR message and this set up is not doing it. i have an edit text box in my window and all im getting is the keydown message when i type to it.
LRESULT CALLBACK GetMsgProc(int code, WPARAM wParam, LPARAM lParam){ if(code == HC_ACTION){ MSG* pMsg = (MSG*)lParam; if(pMsg->message == WM_CHAR){ int i=0; i = i +10;//test for WM_CHAR breakpoint } } return CallNextHookEx(g_KeybdHook, code, wParam, lParam); }
hook in main:g_KeybdHook = SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, 0,GetCurrentThreadId());
thankslParam is not a MSG pointer in a keyboard hook proc. See KeyboardProc Function[^]. It seems to me it would be simpler to subclass the edit control than to use a keyboard hook. Safe Subclassing in Win32[^] Mark
Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the letter Z
-
lParam is not a MSG pointer in a keyboard hook proc. See KeyboardProc Function[^]. It seems to me it would be simpler to subclass the edit control than to use a keyboard hook. Safe Subclassing in Win32[^] Mark
Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the letter Z
hi mark, im using "WH_GETMESSAGE" one of the options here and i should be dealing with this GetMsgProc Function right? obviously not since is not working :sigh: what tells you that im dealing with "keyboard hook proc", more importantly how do i fix it. im practicing to write a dll so i want to get my head around this hooking business. Thank You
-
hi mark, im using "WH_GETMESSAGE" one of the options here and i should be dealing with this GetMsgProc Function right? obviously not since is not working :sigh: what tells you that im dealing with "keyboard hook proc", more importantly how do i fix it. im practicing to write a dll so i want to get my head around this hooking business. Thank You
Lamefif wrote:
im using "WH_GETMESSAGE"
:doh: Got it. I apparently can't read :) Your code works for me. What's going wrong on your end? Mark
Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the letter Z
-
Lamefif wrote:
im using "WH_GETMESSAGE"
:doh: Got it. I apparently can't read :) Your code works for me. What's going wrong on your end? Mark
Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the letter Z
-
Try this message loop:
g_KeybdHook = SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, 0,GetCurrentThreadId());
while (GetMessage(&msg, 0, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}UnhookWindowsHookEx(g_KeybdHook);
Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the letter Z
-
Try this message loop:
g_KeybdHook = SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, 0,GetCurrentThreadId());
while (GetMessage(&msg, 0, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}UnhookWindowsHookEx(g_KeybdHook);
Mark Salsbery Microsoft MVP - Visual C++ This episode brought to you by the letter Z
:laugh: Thank You ps have you any idea how to load and use .klc files done with Microsoft Keyboard Layout Creator
-
:laugh: Thank You ps have you any idea how to load and use .klc files done with Microsoft Keyboard Layout Creator