Public Declare Function GetComboBoxInfo Lib "user32" _
(ByVal hwndCombo As Long, _
CBInfo As COMBOBOXINFO) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Type POINTAPI
x As Long
y As Long
End Type
Public CBI As COMBOBOXINFO
Public Type COMBOBOXINFO
cbSize As Long
rcItem As RECT
rcButton As RECT
stateButton As Long
hwndCombo As Long
hwndEdit As Long
hwndList As Long
End Type
Public n_Items As Long, Item_n As Long
Public Items As String
Public El_Item As String
Public length As Long
Public Handle as Long 'hWnd de la ventana del combo
' Mensajes y valores para los ComboBox
Public Const CB_GETCOUNT = &H146
Public Const CB_GETCURSEL = &H147
Public Const CB_GETLBTEXT = &H148
Public Const CB_GETLBTEXTLEN = &H149
Public Cor As POINTAPI,Ret as Long
Public hParent As Long, ClassName As String
Private Sub Timer1_Timer()
'Obtiene la coordenada del Mouse
Ret = GetCursorPos(Cor)
'Recuperamos el HWND de la ventana asociada a esa coordenada
Handle = WindowFromPoint(Cor.x, Cor.y)
'Handle de la ventana padre
hParent = GetParent(Handle)
'Llenamos un Buffer
ClassName = Space$(128)
'Recupera el Classname y lo devuelve en el Buffer
Ret = GetClassName(Handle, ClassName, 128)
'Extraemos el nombre de la clase
ClassName = LCase(Left$(ClassName, Ret))
' Cantidad de caracteres del texto
Caption_Ventana = String(GetWindowTextLength(Handle), Chr$(0))
'Retorna el caption
Call GetWindowText(Handle, Caption_Ventana, 100)
'Obtiene la coordenada del Mouse de la ventana activa
Call ScreenToClient(Handle, Cor)
'Esta es la rutina que lee el combobox
If ClassName = "combolbox" Then
CBI.cbSize = Len(CBI)
Call GetComboBoxInfo(Handle, CBI)
Item_n = SendMessage(CBI.hwndEdit, CB_GETCURSEL, 0, 0)
length = SendMessage(CBI.hwndEdit, CB_GETLBTEXTLEN, Item_n, 0)
El_Item = Space$(length + 1)
' La variable " el_Item " pasada a SendMessage retorna el dato del Item actual
length = SendMessage(CBI.hwndEdit, CB_GETLBTEXT, Item_n, ByVal El_Item)
El_Item = Left(El_Item, Len(El_Item) - 1)
End Sub
End Sub