Tooltip in TreeView control

K

kuchuk

Hi,
I have a TreeView control in my project (I am working with VS2003, C#).
I also have a tooltip attached to it, which I use to display special
information once user places (MouseMove) the mouse on a TreeNode.
The TreeView control has a basic behaviour that once a TreeNode text
(name) exceeds the size of the control, a tooltip is displaying the
TreeNode text (name). now I have two tooltips showing:
1. treenode text (name).
2. my special information.
My aim is to prevent the first tooltip from showing. I tried to
override WndProc() in the following way:

protected override void WndProc(ref Message m)
{
if(m.Msg == TTN_SHOW)
{
//ignore tooltip show message
return;
}

base.WndProc (ref m);
}

IT DID NOT WORK!
I defined TTN_SHOW to be (found it in commctrl.h):
TTN_FIRST = (0U-520U)
TTN_SHOW = (TTN_FIRST - 1)
Apperantly this is not the message the control receives :(
could somone explain why?
 
C

Claes Bergefall

Try this:

private const int TVS_NOTOOLTIPS = 0x80;
protected override System.Windows.Forms.CreateParams CreateParams
{
get
{
CreateParams p = base.CreateParams;
p.Style = p.Style | TVS_NOTOOLTIPS;
return p;
}
}

/claes
 
C

Claes Bergefall

Strange, that should work. You did inherit the TreeView and put the code in
there, right?
You could look into using the TVS_INFOTIP style. That should give you a
chance to modify the default tooltip text.

/claes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top