1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
Option Explicit
Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
HighlightLBItem List1.hwnd, X, Y
End Sub
Public Sub HighlightLBItem(ByVal LBHwnd As Long, _
ByVal X As Single, ByVal Y As Single)
Dim ItemIndex As Long
Dim AtThisPoint As POINTAPI
AtThisPoint.X = X \ Screen.TwipsPerPixelX
AtThisPoint.Y = Y \ Screen.TwipsPerPixelY
Call ClientToScreen(LBHwnd, AtThisPoint)
ItemIndex = LBItemFromPt(LBHwnd, AtThisPoint.X, _
AtThisPoint.Y, False)
If ItemIndex <> SendMessage(LBHwnd, LB_GETCURSEL, 0, 0) Then
Call SendMessage(LBHwnd, LB_SETCURSEL, ItemIndex, 0)
End If
End Sub |
Partager