views:

17

answers:

1

gMsgHook = SetWindowsHookEx(WH_KEYBOARD_LL, GetMsgHookProc, ghInstDll, 0);

.......

extern "C" HOOK_DLL_API LRESULT CALLBACK GetMsgHookProc(int nCode, WPARAM wParam, LPARAM     lParam)
{
 if (nCode < 0){
   CallNextHookEx(gMsgHook, nCode, wParam, lParam);
 }

 KBDLLHOOKSTRUCT *dl = (KBDLLHOOKSTRUCT*)wParam;

 if (nCode >= HC_ACTION){
  // message mirror to hEdit1
  // doesnt typing work
  SendMessage(hEdit1, wParam, wParam, lParam);
 }

  return CallNextHookEx(gMsgHook, nCode, wParam, lParam);
}
A: 

There are numerous errors in your code snippet.

First, the KBDLLHOOKSTRUCT that is passed to the hook is in lParam, not wParam. wParam contains the window message.

Second, you pass the lParam as is to the edit control. You need to construct the appropriate lParam (see the documentation for WM_KEYDOWN, WM_KEYUP, etc.).

Third, you pass wParam to the hook proc (which is the message) as the wParam for the regenerated keyboard message - it should be the virtual key code that you get from the KBDLLHOOKSTRUCT.

Fourth, if nCode < 0 you'll wind up calling CallNextHookEx twice.

Michael
thanks Michaeli re trying it
gre