'---------------------------------
'GetControlHandleByWindowFromPoint
'Ne fonctionne pas pour les Controls de UserForms
'---------------------------------
ben par rapport à ta démo nonil faut aller chercher le Pane pour savoir si le curseur est dans la ComboBox de feuille ou sa DropDown zone.
Function GetControlHandleByWindowFromPoint(Ctl As Object) As LongPtr
Dim Hold As POINTAPI, clss$, hwnd&, hwndP&
'Position curseur
GetCursorPos Hold
#If Win64 Then
hwnd = WindowFromPoint(PointToLongLong(Hold))
#Else
hwnd = WindowFromPoint(Hold.x, Hold.y)
#End If
'ListBox
Select Case True
Case TypeOf Ctl Is MSForms.ListBox
GetControlHandleByWindowFromPoint = hwnd
Exit Function
Case TypeName(Ctl) = "ComboBox"
clss = Space$(255)
hwndP = GetParent(hwnd)
GetClassName hwndP, clss, 255
If InStr(1, clss, "F3 MdcPopup") = 0 Then hwnd = 0 ' si c'est un popu alors
End Select
GetControlHandleByWindowFromPoint = hwnd
End Function
Function GetControlHandleByWindowFromPoint(Ctl As Object) As LongPtr
Dim Hold As POINTAPI, clss$, hwnd&, hwndP&
'Position curseur
GetCursorPos Hold
#If Win64 Then
hwnd = WindowFromPoint(PointToLongLong(Hold))
#Else
hwnd = WindowFromPoint(Hold.x, Hold.y)
#End If
Select Case True
Case TypeOf Ctl Is MSForms.ListBox Or TypeOf Ctl Is Frame
GetControlHandleByWindowFromPoint = hwnd
Case TypeName(Ctl) = "ComboBox"
clss = Space$(255)
hwndP = GetParent(hwnd)
GetClassName hwndP, clss, 255
If InStr(1, clss, "F3 MdcPopup") = 0 Then hwnd = 0 ' si c'est un popu alors
Case Else: hwnd = 0
End Select
GetControlHandleByWindowFromPoint = hwnd
End Function