WindowUnderMouse = WindowFromPoint(tPT.x, tPT.y)Įnd Function Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _īyVal hWnd1 As Long, ByVal hwnd2 As Long, _īyVal lpsz1 As String, ByVal lpsz2 As String) As Long ' in function WindowProc If Lmsg = WM_MOUSEWHEEL Then If WindowUnderMouse = LocalHwnd ThenĮnd If End If ' in Sub WheelHook dim hForm as long, hCtrl as long Private Declare Function WindowFromPoint Lib "user32" ( _īyVal xPoint As Long, ByVal yPoint As Long) As Long Private Declare Function GetCursorPos Lib "user32.dll" ( _īyRef lpPoint As POINTAPI) As Long Function WindowUnderMouse() As Long Dim tPT As POINTAPI If interested try including the following ' in the declarations area Private Type POINTAPI But if assuming only one listbox on the form could return it's handle and then only call the scroll code if the mouse is over the Though the Listbox does have one (albeit not one that can be uniquely determined if the form has multiple listboxes or combos). Most userform controls are 'windowless', ie without a handle, MyForm.MouseWheel Rotation As written with the above changes mouse scroll should work but probably even if the mouse is not directly over the Listbox, or even when the mouse is not over the form. There are a couple of things wrong, in the normal module changeĭim MyForm As UserForm1 (or the name of the form)
0 Comments
Leave a Reply. |