Visual Basic Programming Code Examples Visual Basic > Database SQL Stuff Code Examples Shows text property of ListBox in ToolTip Shows text property of ListBox in ToolTip 'Shows the text property of a listbox in the tooltip property, 'when the mouse hovers over the listbox for a second. Relies 'on the SendMessage API, declared in the API_Routines file. Public Function ShowListTTip(Button As Integer, Shift As Integer, X As Single, Y As Single, ListBox As ListBox) As String ' Show tool tip message Dim lXPoint As Long Dim lYPoint As Long Dim lIndex As Long ' If Button = 0 Then ' No button was pressed 'Get the x/y position of the mouse on the screen. 'in "TwipsPerPixel" (X and Y) lXPoint = CLng(X / Screen.TwipsPerPixelX) lYPoint = CLng(Y / Screen.TwipsPerPixelY) ' With ListBox ' find which listbox item the mouse is hovering over. lIndex = SendMessage(.hWnd, LB_ITEMFROMPOINT, 0, ByVal ((lYPoint * 65536) + lXPoint)) ' show the tooltip or clear last one, make sure the index is 'greater than or equal to 0 and not greater than the listcount If (lIndex >= 0) And (lIndex <= .ListCount) Then .ToolTipText=".List(lIndex)" 'Return the text=".list(lIndex)" Else .ToolTipText 'Return nothing End If End With '(ListBox) End If '(button=0) End Function