dcsimg
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB5,VB6
Expertise: Intermediate
Aug 19, 2000

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


ListBoxTooltip - A class for displaying items' values in a tooltip

' --- The ListBoxTooltip class
'
' Usage in the client form:
'
'    Dim lstTT As New ListBoxTooltip
'
'    Private Sub Form_Load()
'        Set lstTT.ListBox = List1
'      End Sub
'    Private Sub Form_Unload(Cancel As Integer)
'        Set lstTT.ListBox = Nothing
'    End Sub

Public WithEvents ListBox As ListBox

Private Sub ListBox_MouseMove(Button As Integer, Shift As Integer, X As Single, _
    Y As Single)
    Dim oldFont As StdFont, itemIndex As Long
    
    ' since a listbox doesn't have a TextHeight method
    ' we must borrow it from its Parent
    With ListBox.Parent
        Set oldFont = .Font
        Set .Font = ListBox.Font
        ' determine which element the mouse is on
        itemIndex = Y \ .TextHeight("A") + ListBox.TopIndex
        ' restore fonts
        Set .Font = oldFont
    End With
    
    ' set the tooltip to the current item's string
    If itemIndex < ListBox.ListCount Then
        ListBox.ToolTipText = ListBox.List(itemIndex)
    Else
        ListBox.ToolTipText = ""
    End If

End Sub
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date