Function IsScrollable(control As Object) As Boolean
Dim PosControl As IAccessible, pos As POINTAPI, ok As Boolean, role, Q&, obj
Select Case True
Case TypeOf control Is ComboBox: role = 33
Case TypeName(control) = "ListBox": role = 33
Case TypeName(control) = "Frame": role = 20
End Select
GetCursorPos pos
'pour sortir en cas de control non géré qui n'appelerait donc pas la mouseWheel quand on est dans une feuille
'Set obj = ActiveWindow.RangeFromPoint(pos.X, pos.Y)
'If Not TypeName(obj) = "Range" Then If obj.Name <> control.Name Then IsScrollable = False: Exit Function
re:
#If Win64 Then
Dim lngPtr As LongPtr
CopyMemory lngPtr, pos, LenB(pos)
AccessibleObjectFromPoint lngPtr, PosControl, 0
CopyMemory lngPtr, 0, LenB(pos)
#Else
AccessibleObjectFromPoint pos.X, pos.Y, PosControl, 0
#End If
'rattrapage pour choper la combo developpée
If PosControl.accRole <> role Then
If TypeOf control Is ComboBox And Q = 0 Then Q = 1: pos.Y = pos.Y + 25: GoTo re
End If
On Error Resume Next
[c1] = PosControl.accRole
IsScrollable = PosControl.accRole = role
End Function