Hi,
i created a control that hooks a keyboard to find out if a specific key is
pressed.
KeyboardHandle = SetWindowsHookEx(WH_KEYBOARD_LL, callback,
Marshal.GetHINSTANCE([Assembly].GetExecutingAssembly.GetModules()(0)).ToInt32,
0)
The problem i have is that more than one instance of this control is running
and each control is capable of finding out if a specific key is pressed only
1 handle is activated. probably the0 for the threadid in the
setwindowshookex does this, but all controls are withing the same thread, so
how can i use the hooking for different controls within the same
program.....
Thanks.
CALLBACK FUNCTION:
Private Function KeyboardCallback(ByVal Code As Integer, ByVal wParam As
Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer
On Error Resume Next
If CBool(lParam.flags And LLKHF_UP) Then 'only check keyup events!
If Code = HC_ACTION Then 'normal key pressed
'check if a specific key is pressed
End If
End If
End If
'now send the key further on.
Return CallNextHookEx(KeyboardHandle, Code, wParam, lParam)
End Function