Declare PtrSafe Function WindowFromPoint Lib "user32" Alias "WindowFromPoint" (ByVal Point As LongLong) As LongPtr
Declare PtrSafe Function WindowFromPoint Lib "user32" Alias "WindowFromPoint" (ByVal xPoint As Long, ByVal yPoint As Long) As LongPtr
Function PointToLongLong(point As POINTAPI) As LongLong
Dim ll As LongLong
Dim cbLongLong As LongPtr
cbLongLong = LenB(ll)
' make sure the contents will fit
If LenB(point) = cbLongLong Then
CopyMemory ll, point, cbLongLong
End If
PointToLongLong = ll
End Function
#If VBA7 Then
'DECLARATION VBA7
Private Declare PtrSafe Function GetCursorPos Lib "user32" (ByRef lpPoint As POINTAPI) As LongPtr 'MAYBE Long
#If Win64 Then
'seulement pour le vba7 en 64
Private Declare PtrSafe Function WindowFromPoint Lib "user32" (ByVal Point As LongLong) As LongPtr '_
Private Type POINTAPI: XY As LongLong: End Type
#Else
'seulement pour le vba7 en 32
Private Declare PtrSafe Function WindowFromPoint Lib "user32" (ByVal xPoint As LongPtr, ByVal yPoint As LongPtr) As LongPtr
Private Type POINTAPI: X As Long: Y As Long: End Type
#End If
#Else
'DECLARATION VB6
#End If
Function HandleUnderCursor()
Dim PoS As POINTAPI
GetCursorPos PoS
#If Win64 Then
HandleUnderCursor = WindowFromPoint(PoS.XY) & " en mode 64"
#Else
HandleUnderCursor = WindowFromPoint(PoS.X, PoS.Y) & " en mode 32"
#End If
End Function
oui dans ma version 4 c'est ça le move sur la combo me donne le rect si elle est deployéeOn obtient le RECT des ComboBoxes quand elles sont déployées.
La question est maintenant de savoir quand elles sont déployées.
Function PointToLongLong(point As POINTAPI) As LongLong
Dim ll As LongLong
Dim cbLongLong As LongPtr
cbLongLong = LenB(ll)
' make sure the contents will fit
If LenB(point) = cbLongLong Then
CopyMemory ll, point, cbLongLong
End If
PointToLongLong = ll
End Function
Private Type POINTAPI: X As Long: Y As Long: End Type
Private Type POINTAPI: XY As LongLong: End Type
GetCursorPos Hold
#If Win64 Then
hWnd = WindowFromPoint(PointToLongLong(Hold))
#Else
hWnd = WindowFromPoint(Hold.x, Hold.y)
#End If
ben c'est ni plus ni moins que l'astuce de mon fichier 4J'ai trouvé un subterfuge pour les ComboBoxes UserForm.
Alors ça marche chez moi en 64Bits à une différence près:
- Le RECT d'une ComboBox ActiveX inclut la zone de valeur => il faudrait la retirer.
- Le RECT d'une ComboBox UserForm N'inclut PAS la zone de valeur
Fonctionnement: Si la fenêtre de ComboBox n'est pas déployée, on ne fait rien, sinon on positionne le curseur en haut à droite du RECT de la ComboBox et on affiche le message.
A essayer en 32Bits.