Hot Tracking on a listbox 
Author Message
 Hot Tracking on a listbox

Hi!

        How can I add hot traking (the item gets selected just by
hovering the mouse over it) to a listbox (not listview)? O:-)

      Fernando Rodriguez Romero

      frr at pobox dot com



Mon, 04 Jun 2001 03:00:00 GMT  
 Hot Tracking on a listbox

Quote:

>Hi!

>        How can I add hot traking (the item gets selected just by
>hovering the mouse over it) to a listbox (not listview)? O:-)

Use the following code in the Listbox MouseMove event:

Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single,
Y As Single)
    Dim fntHold As Font, iHeight As Integer, iItem As Integer
    Set fntHold = Me.Font
    Me.Font = List1.Font
    iHeight = Me.TextHeight("A")
    Me.Font = fntHold
    iItem = Y / iHeight
    List1.ListIndex = iItem
End Sub

You need to get the height of one line of text in the listbox, however, a
listbox doesn't have a TextHeight property.  The first 5 lines of code change
the Form's font to the same font as the listbox, gets the height of a line
using the Form's TextHeight property, and then resets the form back to its
original font.

Lee Weiner
weiner AT fuse DOT net



Wed, 06 Jun 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Hot Tracking

2. REPOST: Hot tracking

3. How do I implement hot tracking on a button control?

4. Move ListBox items to another ListBox

5. Store Text in Listbox.Editing, and storing in Listbox

6. VB3: Setting listbox based on value of other listbox

7. Write contents of listbox to text file/populate listbox from text file

8. How to scroll a listbox and scroll another listbox along

9. HELP: ListBox scrolling Q (listbox)

 

 
Powered by phpBB® Forum Software