473,320 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

ToolTip for ListBox-/ComboBox-Items

Hi!

If you move the mouse over an item that's part of a treeview and wider
than the treeview, a tooltip showing the full item text will be
displayed. I try to do this for ListBoxes and ComboBoxes.
For ListBoxes I got it working, but not for the ListBox part of
ComboBoxes. Do you know any sample code?

Thanks in advance!
Timo
--
www.TimoSoft-Software.de
Stop software patents!
Nov 20 '05 #1
11 18299
* Timo Kunze <TK*********@gmx.de> scripsit:
If you move the mouse over an item that's part of a treeview and wider
than the treeview, a tooltip showing the full item text will be
displayed. I try to do this for ListBoxes and ComboBoxes.

For ListBoxes I got it working, but not for the ListBox part of
ComboBoxes. Do you know any sample code?


Untested: Handle the combobox's 'WM_CTLCOLORLISTBOX' message. This message will be sent if the listbox part of the combobox is created. In the 'lParam' parameter you will receive the handle to the listbox part, then you can use the 'NativeWindow' class to handle the listbox part's events.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 20 '05 #2
Herfried K. Wagner [MVP] schrieb:
Untested: Handle the combobox's 'WM_CTLCOLORLISTBOX' message. This message will be sent if the listbox part of the combobox is created. In the 'lParam' parameter you will receive the handle to the listbox part, then you can use the 'NativeWindow' class to handle the listbox part's events.


Hello Herfried,

the problem is not to get the listbox handle (I used the DropDown event
and the GetComboBoxInfo api method), but to use it for further
processing. 'NativeWindow' seems the way to go, but can I use the
ToolTip class for NativeWindows? It doesn't seem so - so the next step
probably is writing a custom ToolTip class. Hmmm, smells like work, but
that's life I guess...
I hope .net 2.0 will simplify customizing a ComboBox' list portion.

Thank you!
Timo
--
www.TimoSoft-Software.de
Stop software patents!
Nov 20 '05 #3
Okay, my ToolTip class is working now. However, there seems to be a hook
eating all messages that the ListBox portion would normally receive.
Neither the ListBox nor the ComboBox receive WM_MOUSEMOVE or any other
mouse message.
I'll set up my own mouse hook now. It's "funny": So much work for such a
small thing. :P

Timo
--
www.TimoSoft-Software.de
Stop software patents!
Nov 20 '05 #4
Timo,

* Timo Kunze <TK*********@gmx.de> scripsit:
Okay, my ToolTip class is working now. However, there seems to be a
hook eating all messages that the ListBox portion would normally
receive. Neither the ListBox nor the ComboBox receive WM_MOUSEMOVE or
any other mouse message.


I am able to receive the 'WM_MOUSEMOVE' message for the listbox part
using this code (no cleanup code included yet):

\\\
Imports System.Runtime.InteropServices

Public Class ExtendedComboBox
Inherits System.Windows.Forms.ComboBox

Private Const WM_CTLCOLORLISTBOX As Int32 = &H134

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_CTLCOLORLISTBOX Then
Dim n As New Foo()
n.AssignHandle(m.LParam)
End If
MyBase.WndProc(m)
End Sub
End Class

Public Class Foo
Inherits System.Windows.Forms.NativeWindow

Private Const WM_MOUSEMOVE As Int32 = &H200

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_MOUSEMOVE Then
Debug.WriteLine("Foo the bar")
End If
MyBase.WndProc(m)
End Sub
End Class
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 20 '05 #5
Hmmm, well, this makes my mouse hook useless. :)

However, I got all the stuff almost working and have come to the
conclusion that giving the Combo's own listbox portion ToolTips probably
is impossible (at least it's easier to use a custom ListBox as dropdown
window). There're 2 big problems:
1) LB_ITEMFROMPOINT always returns 0 in the lower 16 Bit, so I've no
clue which item the cursor is over. Since it works for stand-alone
ListBoxes, I asume the ComboBox is eating this message.
2) The ToolTip gets displayed, but it's always covered by the listbox
portion. If I use SetWindowPos to change Z-order, the combobox will
immediately close up.

I'll try some things, but I'll probably take the other way and display
my own dropdown window.

Thanks for your help.
Timo
--
www.TimoSoft-Software.de
Stop software patents!
Nov 20 '05 #6
Timo,

* Timo Kunze <TK*********@gmx.de> scripsit:
However, I got all the stuff almost working and have come to the
conclusion that giving the Combo's own listbox portion ToolTips
probably is impossible (at least it's easier to use a custom ListBox
as dropdown window). There're 2 big problems:

1) LB_ITEMFROMPOINT always returns 0 in the lower 16 Bit, so I've no
clue which item the cursor is over. Since it works for stand-alone
ListBoxes, I asume the ComboBox is eating this message.
Can you post the source code (if you still have it)?

Maybe, you can make the combobox ownerdrawn and handle the 'DrawItem'
event to get the highlighted item.
I'll try some things, but I'll probably take the other way and display
my own dropdown window.


<URL:http://vbaccelerator.com/article.asp?id=13309>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 20 '05 #7
Herfried K. Wagner [MVP] schrieb:
1) LB_ITEMFROMPOINT always returns 0 in the lower 16 Bit, so I've no
clue which item the cursor is over. Since it works for stand-alone
ListBoxes, I asume the ComboBox is eating this message.

Can you post the source code (if you still have it)?

http://www.timosoft-software.de/down...oxToolTip2.zip
Look for the TODO in CToolTipListBox.vb.
Maybe, you can make the combobox ownerdrawn and handle the 'DrawItem'
event to get the highlighted item.

I'll try it.

Timo
--
www.TimoSoft-Software.de
Stop software patents!
Nov 20 '05 #8
I implemented OwnerDraw and now it works in a satisfying way.

Here's the code:
http://www.timosoft-software.de/down...oxToolTip3.zip

Timo
--
www.TimoSoft-Software.de
Stop software patents!
Nov 20 '05 #9
* Timo Kunze <TK*********@gmx.de> scripsit:
I implemented OwnerDraw and now it works in a satisfying way.

Here's the code:
http://www.timosoft-software.de/down...oxToolTip3.zip


Thank you! Is it "by design" that the tooltip is shown /below/ the list
portion of the combobox?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #10
Herfried K. Wagner [MVP] schrieb:
Thank you! Is it "by design" that the tooltip is shown /below/ the list
portion of the combobox?

Yes. I did this, because there seems to be no way to display it in front
of the list portion. If you call SetWindowPos to change Z-order, the
ComboBox probably thinks (and actually it is right) that the user
switched to another window and hides the list portion.
So displaying the tooltip below the list is still better than having it
partially covered.

Timo
--
www.TimoSoft-Software.de
Stop software patents!
Nov 20 '05 #11
* Timo Kunze <TK*********@gmx.de> scripsit:
Thank you! Is it "by design" that the tooltip is shown /below/ the list
portion of the combobox?


Yes. I did this, because there seems to be no way to display it in
front of the list portion. If you call SetWindowPos to change Z-order,
the ComboBox probably thinks (and actually it is right) that the user
switched to another window and hides the list portion.

So displaying the tooltip below the list is still better than having
it partially covered.


I remember you mentioned this problem in a previous post. So, the
"cleanest" solution is maybe writing your own combobox control based on
the vbAccelerator sample, but this would be a lot of work too...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: hiroshi ochi | last post by:
Hello, Using MSIE 6.0 and above, with javascript is it possible to display an individual tooltip for each item in a listbox? I need this functionality to show the listitems that are longer...
6
by: Robert | last post by:
Hello. I have been trying out the Lebans ToolTip Classes at http://www.lebans.com/tooltip.htm, to display "balloon" style help tips in a form. The classes I am using are located at...
6
by: Jim H | last post by:
I have a dialog that I bring up as an options dialog. I have a variable for this dialog as a member of the main application form and I create it in the constructor. I bring up the dialog by...
2
by: cd | last post by:
Is it possible to add a tool tip to an asp .net listbox control utilizing javascript or another method? I would like to add a tooltip when the user hovers over the item in the listbox. I was...
4
by: Tim Zych | last post by:
I'm displaying a tooltip related to a listbox based on the selected item. It works well except when I move the cursor away from the listbox and then hover back over it, the tooltip pops up...
4
by: srichand | last post by:
Hi All, Can somebody help me out in adding a tooltip to a listbox using js....
0
by: LaksM | last post by:
Hi, I need to create a combox/listbox with certain fixed width. In that I need to display large text. I can use Hscroll for list box. But, is there a way to display the text as tooltip/mouse over...
8
by: amitjaura | last post by:
Can anybody guide me how to use tooltip on listbox
0
by: tshad | last post by:
In VS 2008, is there a way to have the individual list item description to show up in a tooltip when you have your mouse over the list item? I have a list item that has descriptions that are...
0
Pakmarshal
by: Pakmarshal | last post by:
Hello Everyone, While working with list view control in VB 2005, I observed a behavior that the tooltip for the control is not consistent i.e. if we closely observe that when the tooltip displays...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.