|
Определить над каким элементом находится курсор мыши |
|
|
Добавьте на форму элемент ListBox. Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const LB_ITEMFROMPOINT = &H1A9
Private Sub Form_Load()
With List1
.AddItem "Hello World"
.AddItem "Hello Again"
.AddItem "Just Example "
End With
End Sub
Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim xPosition As Long
Dim yPosition As Long
Dim i As Long
If Button = 0 Then ' если никакие кнопки не нажаты
xPosition = CLng(X / Screen.TwipsPerPixelX)
yPosition = CLng(Y / Screen.TwipsPerPixelY)
With List1
' взять выбранный элемент из листа
i = SendMessage(.hwnd, LB_ITEMFROMPOINT, 0, ByVal ((yPosition * 65536) + xPosition))
'подсветить подсказку к элементу
If (i >= 0) And (i <= .ListCount) Then
.ToolTipText = .List(i)
Text1.Text = .List(i)
Else
.ToolTipText = ""
End If
End With
End If
End Sub
|
|
|
|
|
|
|