Results 1 to 9 of 9

Thread: ToolTipText and listbox control

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Location
    Rochester NY, USA
    Posts
    93
    is it possible to set ToolTipText on each element of a listbox? I haven't found this to be an option but I thought I'd ask and see if I was overlooking something..

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You can make an array to hold all tooltips, and in the mouseover event put it to recognize which one its over, thats a bit hard but you have the y var from the event and topindex property from the list, so you only need to know what height each item are. This maybe you should experiment by your own using the textheight and the font to another object.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Lightbulb

    Actually, it is very easy to do. Here's an example:
    Code:
    Option Explicit
    Private Type POINTAPI
        X As Long
        Y As Long
    End Type
    Private Declare Function LBItemFromPt Lib "comctl32.dll" (ByVal hwnd As Long, ByVal ptx As Long, ByVal pty As Long, ByVal bAutoScroll As Long) As Long
    Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
    
    
    Private Sub Form_Load()
        Dim i As Integer
        
        For i = 1 To 10
            List1.AddItem "Item" & i
        Next
    End Sub
    
    
    Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Dim intCurItem As Long
        Dim pt As POINTAPI
        Dim strItem As String
    
        'adjust to the expected values
        pt.X = X \ Screen.TwipsPerPixelX
        pt.Y = Y \ Screen.TwipsPerPixelY 'and map to the client coordinates
        Call ClientToScreen(List1.hwnd, pt) 'get the item nearest the cursor
        intCurItem = LBItemFromPt(List1.hwnd, pt.X, pt.Y, False)
        If intCurItem > -1 Then
            List1.ToolTipText = List1.List(intCurItem)
        End If
    End Sub

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Question

    Wow, what happened to Coding Colors ?????

  5. #5
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    Does anybody know how to position the tooltip exactly above the listbox's item, so it lookes as if the text is completed by the tooltip?

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Location
    Rochester NY, USA
    Posts
    93
    Thanks Serge.. that looks like what I need. I was thinking along those lines but I didn't know how to get the item that the mouse was over. As far as the color.. I don't know.. I've never been able to get my posts to show the VB color. *shrug*

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    well, then it's not a tooltip then. Or is it? You can find the hwnd of the tooltib with findwindow and then move it with movewindow, i don't know if the tooltip is a hwnd at all..

    Serge: The colors are gone yeah, but worse, it puts extra lines after each line. Also, How did u get a Guru with 2k posts?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Smile

    kedaman, I've noticed that after the last update they made on the UBB, they lost coloring functionality.

    As for number of posts, I've been an active member on this UBB since February 1999, so I guess that's how many posts I have sice then.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Location
    Rochester NY, USA
    Posts
    93

    Thumbs up

    I Just put that code in there and it works like a champ. I was afraid that it wouldn't display the new tooltip when the mouse was moved (like you'd have to move off of the box and back on) but it updates as you move down the list. Thanks again.. exactly what I was looking for.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width