Type MOUSEHOOKSTRUCT pt As POINTAPI hwnd As Long wHitTestCode As Long dwExtraInfo As Long End Type Declare Function SetWindowsHookEx Lib user32 Alias SetWindowsHookExA ( _ ByVal idHook As Long, _ ByVal lpfn As Long, _ ByVal hmod As Long, _ ByVal dwThreadId As Long _ ) As Long Declare Function CallNextHookEx Lib user32 ( _ ByVal ghHook As Long, _ ByVal ncode As Long, _ ByVal wParam As Integer, _ ByVal lParam As Long _ ) As Long Declare Function UnhookWindowsHookEx Lib user32 ( _ ByVal ghHook As Long _ ) As Long Declare Sub CopyMemory Lib kernel32 Alias RtlMoveMemory ( _ Destination As Any, _ Source As Any, _ ByVal Length As Long) ----- Public Function MouseProc (ByVal ncode As Long, ByVal wParam As Long, _ ByVal lParam As Long) As Long Documentation says to do this If ncode < 0 Then Forward message and get out MouseProc = CallNextHookEx(ghHook, ncode, wParam, lParam) Exit Function End If Get MOUSEHOOKSTRUCT pointed to by lParam CopyMemory mhs.pt.x, ByVal lParam, LenB(mhs) Fill text box with message data sText = MsgID: & wParam sText = sText & vbCrLf & For window: & Hex$ (mhs.hwnd) sText = sText & vbCrLf & X: & mhs.pt.x & Y: & mhs.pt.y sText = sText & vbCrLf & Hit test: & GetConstant(mhs.wHitTestCode) frmMain.txtMsg.Text = sText Forward to next hook |