Results 1 to 6 of 6

Thread: listbox control and tooltiptext

  1. #1

    Thread Starter
    Hyperactive Member cajsoft's Avatar
    Join Date
    Aug 2000
    Location
    Glasgow, Scotland
    Posts
    295

    listbox control and tooltiptext

    Hi,
    is it possible to display the tooltip of an item in a list box without selecting the item, ie. hovering above the item?

    Thanks.
    Craig Johnstone, MCP,CNA

    VB 6,SQL,Lotus Notes,Crystal Reports 7,8

    http://www.cajsoft.co.uk/downloads.htm

  2. #2
    Fanatic Member
    Join Date
    Sep 2000
    Location
    Over There
    Posts
    522
    Look at This Thread


    If you can't figure out how to apply it to what you want, post again and i'll explain it.
    It Never Fails. Everytime I try to make a program idiot proof, the world makes a better idiot.

  3. #3

    Thread Starter
    Hyperactive Member cajsoft's Avatar
    Join Date
    Aug 2000
    Location
    Glasgow, Scotland
    Posts
    295
    No, thats not what I'm looking for. It doesnt help. I need to use the MouseMove event or something similar.

    anyone else?
    Craig Johnstone, MCP,CNA

    VB 6,SQL,Lotus Notes,Crystal Reports 7,8

    http://www.cajsoft.co.uk/downloads.htm

  4. #4
    Fanatic Member TokersBall_CDXX's Avatar
    Join Date
    Mar 2003
    Location
    America
    Posts
    571

    Wink This should do the trick for you.

    VB Code:
    1. Private Type POINTAPI
    2.     x As Long
    3.     y As Long
    4. End Type
    5.  
    6. Private Type RECT
    7.         Left As Long
    8.         Top As Long
    9.         Right As Long
    10.         Bottom As Long
    11. End Type
    12.  
    13. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    14. Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
    15. Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
    16. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    17. Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
    18.  
    19. Private Const LB_GETITEMRECT = &H198
    20. Private Const LB_ITEMFROMPOINT = &H1A9
    21.  
    22.  
    23. Public Function ItemFromPoint(ByRef oList As ListBox, ByVal x As Single, ByVal y As Single) As Long
    24.     Dim tPOINT As POINTAPI
    25.     Dim iIndex As Long
    26.     'Get the Mouse Cursor Position
    27.     Call GetCursorPos(tPOINT)
    28.     'Convert the Coords to be Relative to the Listbox
    29.     Call ScreenToClient(oList.hwnd, tPOINT)
    30.     'Find which Item the Mouse is Over
    31.     iIndex = SendMessage(oList.hwnd, LB_ITEMFROMPOINT, 0&, ByVal ((tPOINT.x And &HFF) Or (&H10000 * (tPOINT.y And &HFF))))
    32.     'Extract the List Index
    33.     ItemFromPoint = iIndex And &HFF
    34. End Function
    35.  
    36. Private Sub Form_Load()
    37.     Dim iIndex As Integer
    38.        
    39.     For iIndex = 1 To 100
    40.         List1.AddItem iIndex & " blankdata " & iIndex
    41.     Next
    42. End Sub
    43.  
    44. Private Sub List1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    45.     Dim iIndex As Long
    46.     Static iLastIndex As Long
    47.    
    48.     iIndex = ItemFromPoint(List1, x, y)
    49.     Me.List1.ToolTipText = Me.List1.List(iIndex)
    50. End Sub


    good luck
    Build your own personalized flash based chat room for your webpage for FREE! http://www.4computerheaven.com

  5. #5
    Fanatic Member
    Join Date
    Sep 2000
    Location
    Over There
    Posts
    522
    Exactly.

    Just what the thread I was pointing you to was doing.



    gotta learn to read between the lines.
    It Never Fails. Everytime I try to make a program idiot proof, the world makes a better idiot.

  6. #6

    Thread Starter
    Hyperactive Member cajsoft's Avatar
    Join Date
    Aug 2000
    Location
    Glasgow, Scotland
    Posts
    295
    Thanks tokersball!!

    Dalceon, thanks for trying to help, but your thread was nothing like what tokersball placed.
    Craig Johnstone, MCP,CNA

    VB 6,SQL,Lotus Notes,Crystal Reports 7,8

    http://www.cajsoft.co.uk/downloads.htm

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