65536在这里是什么?
Option Explicit
Const LB_ITEMFROMPOINT = &H1A9
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 Sub Form_Load()
Dim i
For i = 1 To 200
List1.AddItem Str(i) + " ÕâÊǵڶàÉÙÐÐ " + Str(i)
Next i
End Sub
Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lXPoint As Long
Dim lYPoint As Long
Dim lIndex As Long
If Button = 0 Then 'È·¶¨ÔÚÒÆ¶¯Êó±êµÄͬʱûÓа´Ï¹¦Äܼü»òÕßÊó±ê¼ü
'»ñµÃ¹â±êµÄλÖã¬ÒÔÏñËØÎªµ¥Î»
lXPoint = CLng(X / Screen.TwipsPerPixelX)
lYPoint = CLng(Y / Screen.TwipsPerPixelY)
'
With List1
'»ñµÃ ¹â±êËùÔڵıêÌâÐеÄË÷Òý
lIndex = SendMessage(.hwnd, LB_ITEMFROMPOINT, 0, ByVal ((lYPoint * 65536) + lXPoint))
Debug.Print lIndex
'½«ListBoxµÄTooltipÉèÖÃΪ¸Ã±êÌâÐеÄÎı¾
If (lIndex >= 0) And (lIndex <= .ListCount) Then
.ToolTipText = .List(lIndex) 'Return the text = .list(lIndex)
Else
.ToolTipText = ""
End If
End With
End If
End Sub