Private Type POINTAPI
X As Long Y As Long End Type Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private Declare Function ScreenToClient Lib "user32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long Private Const LB_ITEMFROMPOINT = &H1A9 '_________________________________________________________ Private Sub Form_Load() Dim iIndex As Integer 'Fill the List with Dummy Values For iIndex = 1 To 100 List1.AddItem "Really Long List Item " & iIndex Next End Sub '_________________________________________________________ Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim tPOINT As POINTAPI Dim iIndex As Long 'get the Mouse Cursor Position Call GetCursorPos(tPOINT) 'Convert the Coords to be Relative to the Listbox Call ScreenToClient(List1.hWnd, tPOINT) 'Find which Item the Mouse is Over iIndex = SendMessage(List1.hWnd, LB_ITEMFROMPOINT, 0&, ByVal ((tPOINT.X And &HFF) Or (&H10000 * (tPOINT.Y And &HFF)))) If iIndex >= 0 Then 'Extract the List Index iIndex = iIndex And &HFF 'set the Lists ToolTipText List1.ToolTipText = List1.List(iIndex) End If End Sub |