|
-
Apr 30th, 2000, 10:08 PM
#1
Thread Starter
Lively Member
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..
-
Apr 30th, 2000, 10:53 PM
#2
transcendental analytic
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.
-
Apr 30th, 2000, 11:39 PM
#3
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
-
Apr 30th, 2000, 11:41 PM
#4
Wow, what happened to Coding Colors ?????
-
May 1st, 2000, 12:04 AM
#5
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?
-
May 1st, 2000, 12:07 AM
#6
Thread Starter
Lively Member
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*
-
May 1st, 2000, 12:11 AM
#7
transcendental analytic
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.
-
May 1st, 2000, 12:51 AM
#8
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.
-
May 1st, 2000, 01:04 AM
#9
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|