'https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms644986(v=vs.85)
Private Function LowLevelMouseProc(ByVal nCode As Long, ByVal wParam As LongPtr, ByVal lParam As LongPtr) As LongPtr
Dim Bool As Boolean
Dim ErrNumber As Long
Dim Obj As Object
Dim TopIndex As Long
Dim DoNotCallNextHook As Boolean
Static LastTimer As Single
'Test validité du ControlHooked
On Error GoTo gestion_d_erreur 'on fait une gestion globale
'Set Obj = ControlHooked
'ErrNumber = Err.Number
'On Error GoTo 0
'Le ControlHooked a disparu (UserForm fermé Alt + F4 par exemple)
'If ErrNumber <> 0 Or ControlHooked Is Nothing Then
'Call UnHookMouse
'Else
If nCode = HC_ACTION Then
'If Int((Timer - LastTimer) * 100) >= 0 Then
GoSub CheckMouseIsOverTheBox'd'office on attend pas de bouger
'If wParam = WM_MOUSEMOVE Then '???????????
'DoNotCallNextHook = True
'Either on WM_MOUSEMOVE or on WM_MOUSEWHEEL
'GoSub CheckMouseIsOverTheBox ' ca je le met pas là je le met en exécution d'office dans la proc
'End If
If wParam = WM_MOUSEWHEEL Then
'DoNotCallNextHook = True
LowLevelMouseProc = True 'le callback ici
'Either on WM_MOUSEMOVE or on WM_MOUSEWHEEL
'GoSub CheckMouseIsOverTheBox
If Not plHooking = 0 Then
With ControlHooked
'Is the Window still there ?
'TopIndex = .TopIndex
' On Error Resume Next
'.TopIndex = 0
'ErrNumber = Err.Number
'On Error GoTo 0
'If ErrNumber <> 0 Then
' Call UnHookMouse
' Exit Function
'End If
'.TopIndex = TopIndex
'Moves the ScrollBar depending on the mouse wheel, Info is stored in lParam
If GetHookStruct(lParam).mouseData > 0 Then
If .TopIndex < ScrollStep Then .TopIndex = 0 Else .TopIndex = .TopIndex - ScrollStep
Else
.TopIndex = .TopIndex + ScrollStep
End If
End With
End If
End If
'End If
'End If
End If
Exit Function
gestion_d_erreur:
LowLevelMouseProc = CallNextHookEx(0&, nCode, wParam, ByVal lParam)
Exit Function
CheckMouseIsOverTheBox:
If Not ControlHooked Is Nothing Then 'j'ai du mal à comprendre comment dans la proc en addressof tu est besoins de tester le control
' On Error Resume Next
Bool = MouseIsOverTheBox
'ErrNumber = Err.Number
' On Error GoTo 0
'Run time Error 57097: le résultat de l'appel à la fonction MouseMoveFunction() n'est pas significatif, on oublie !
'If ErrNumber <> 57097 Then
'If ErrNumber = 0 Then
'The mouse is not anymore over the ControlHooked Object
' tu a une fonction booleene qui te dis si tu est toujours sur le control ou pas
'et bien ca suffit pour unhooker selon le bool
If Not Bool Then
Call UnHookMouse
End If
'End If
'End If
End If
Return
End Function