Private Sub MouseWheel(control As Object, Optional yy As Single = 0, Optional pilote As control = Nothing)
Const WHEEL_DELTA = 120&, WM_MOUSEWHEEL = &H20A, PM_NOREMOVE = &H0&
Dim tMsg As Msg, lDelta As Integer, pos As POINTAPI, criter As Boolean, tbx ' Modif (tbx ajouté)
Dim posControl As IAccessible, MouseControl As IAccessible
Set MouseControl = control
Do
GetCursorPos pos
#If Win64 Then
Dim lngPtr As LongPtr
CopyMemory lngPtr, pos, LenB(pos)
AccessibleObjectFromPoint lngPtr, posControl, 0
#Else
AccessibleObjectFromPoint pos.x, pos.y, posControl, 0
#End If
If posControl Is Nothing Then Exit Sub
On Error Resume Next ' Modif masquage des erreurs
criter = False ' Modif
criter = (posControl.accName = MouseControl.accName)
If Not criter Then bLooping = False: Exit Sub
On Error GoTo 0 ' Modif gestion des erreurs réactivée
bLooping = True
Call WaitMessage
If PeekMessage(tMsg, NULL_PTR, WM_MOUSEWHEEL, WM_MOUSEWHEEL, PM_NOREMOVE) Then
lDelta = HiWord(tMsg.wParam)
If pilote Is Nothing Then
Select Case TypeName(control)
Case "Frame"
If lDelta > 0& Then
tbx = "moins"
control.ScrollTop = Application.Max(control.ScrollTop - 8, 0)
Else
tbx = "plus"
control.ScrollTop = Application.Min(control.ScrollTop + 8, control.ScrollHeight) ' Modif (control au lieu de Frame1)
End If
Case "ListBox", "ComboBox"
If lDelta > 0& Then
tbx = "moins"
On Error Resume Next
control.TopIndex = Application.Max(control.TopIndex - 1, 0) ' Modif ( , 0 au lieu de , 1)
On Error GoTo 0
Else
tbx = "plus"
On Error Resume Next
control.TopIndex = Application.Min(control.TopIndex + 1, control.ListCount - 1)
On Error GoTo 0
End If
End Select
End If
If Not pilote Is Nothing Then
Select Case TypeName(pilote)
Case "ScrollBar"
If lDelta > 0& Then
tbx = "moins"
pilote.Value = Application.Max(pilote.Value - pilote.LargeChange, pilote.Min)
Else
tbx = "plus"
pilote.Value = Application.Min(pilote.Value + pilote.LargeChange, pilote.Max)
End If
'On peut ici ajouter des control piloté par un autre comme pour le scrollbar
End Select
End If
End If 'End of PeekMessage
DoEvents
Loop Until bLooping = False
End Sub