Hi all! Merry Christmas for tomorrow.
Now to business: I'm using the following code to set a global mouse wheel hook, but the mouse moves very laggy (slow and jerky) when it's hooked. You can try this by running the code and moving the mouse around. So, is there anything I should be doing to make it smooth like there was no hook in effect? Something I've overlooked? Thanks.
Code: Select all
Global MouseWheelHook,MouseWheelWindow,MouseWheelDir
Procedure LowLevelMouseProc(nCode.l,wParam.l,lParam.l)
If wParam=#WM_MOUSEWHEEL
MouseWheelDir=-(EventwParam()>>16)/#WHEEL_DELTA
PostMessage_(MouseWheelWindow,#WM_MOUSEWHEEL,PeekL(lParam+8),0)
EndIf
ProcedureReturn CallNextHookEx_(MouseWheelHook,nCode,wParam,lParam)
EndProcedure
Procedure AddMouseWheelHook(hWnd)
If MouseWheelHook=0
MouseWheelHook=SetWindowsHookEx_(#WH_MOUSE_LL,@LowLevelMouseProc(),GetModuleHandle_(0),0)
EndIf
MouseWheelWindow=hWnd
ProcedureReturn MouseWheelHook
EndProcedure
Procedure RemoveMouseWheelHook()
If MouseWheelHook
UnhookWindowsHookEx_(MouseWheelHook)
MouseWheelHook=0
EndIf
EndProcedure
OpenWindow(0,400,200,640,320,"Mouse Hook",#PB_Window_SystemMenu)
AddMouseWheelHook(WindowID(0)) ; Makes mouse slow and laggy to move.
Repeat
ev=WaitWindowEvent()
Until ev=#PB_Event_CloseWindow