|
-
Mar 31st, 2003, 09:58 AM
#1
Thread Starter
Hyperactive Member
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
-
Mar 31st, 2003, 10:15 AM
#2
Fanatic Member
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.
-
Mar 31st, 2003, 10:23 AM
#3
Thread Starter
Hyperactive Member
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
-
Mar 31st, 2003, 10:25 AM
#4
Fanatic Member
This should do the trick for you.
VB Code:
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
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
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Const LB_GETITEMRECT = &H198
Private Const LB_ITEMFROMPOINT = &H1A9
Public Function ItemFromPoint(ByRef oList As ListBox, ByVal x As Single, ByVal y As Single) As Long
Dim tPOINT As POINTAPI
Dim iIndex As Long
'Get the Mouse Cursor Position
Call GetCursorPos(tPOINT)
'Convert the Coords to be Relative to the Listbox
Call ScreenToClient(oList.hwnd, tPOINT)
'Find which Item the Mouse is Over
iIndex = SendMessage(oList.hwnd, LB_ITEMFROMPOINT, 0&, ByVal ((tPOINT.x And &HFF) Or (&H10000 * (tPOINT.y And &HFF))))
'Extract the List Index
ItemFromPoint = iIndex And &HFF
End Function
Private Sub Form_Load()
Dim iIndex As Integer
For iIndex = 1 To 100
List1.AddItem iIndex & " blankdata " & iIndex
Next
End Sub
Private Sub List1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim iIndex As Long
Static iLastIndex As Long
iIndex = ItemFromPoint(List1, x, y)
Me.List1.ToolTipText = Me.List1.List(iIndex)
End Sub
good luck
-
Mar 31st, 2003, 10:27 AM
#5
Fanatic Member
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.
-
Mar 31st, 2003, 10:59 AM
#6
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|