Solved

Tooltips for custom tree controls

Posted on 2001-07-17
2
629 Views
Last Modified: 2013-12-03
I'm trying to add tooltip support for this CTreeCtrl derived class I'm working on.  I'm testing the control in a dialog by SubclassDlgItem() it.

The problem I have is I want the tree control to do it's own tooltip handling.  I use CToolTipCtrl, but I also tried overloading some CWnd members.  Right now, no matter what I try, the TTN_NEEDTEXT notifications (I use LPSTR_TEXTCALLBACK) always goes to the parent of the tree control, the dialog.  I want this control to be fully self contained so I don't want to have to add message relaying code to forward the messages from the dialog to the tree.

I tried adding ON_NOTIFY_REFLECT/ON_NOTIFY handlers to the tree, changing the hwnd member of the TOOLINFO struct associated w/ the tooltip to point to the tree, all without success.  The tree never gets called.

So I would like to know what I need to do to solve this.  I'd appreciate all the necessary steps, or better even, a source code example of a CTreeCtrl control that handles it's own tooltips.  That would rock.  Thanks!
0
Comment
Question by:asselins
2 Comments
 

Author Comment

by:asselins
ID: 6309488
I solved it by using the generic CWnd support for tooltips.  You call EnableTooltips(TRUE) in the tree control, and then you have to handle TTN_GETDISPINFO to get the messages.  Simple as that.

Since the rect for the tooltip is the whole control, it will remain showing as long as the mouse is over the client area.  This is inconvenient, so you can handle mouse move in the tree control and call the tooltip's Pop() method to make it disappear when the mouse moves.

Also, from the TTN_GETDISPINFO handler, you have to use ::GetMessagePos() and then translate that using ::ScreenToClient() to get the coords relative to the tree's client area.  Then from that you can do standard hittesting to figure out what item was clicked and so on.
0
 
LVL 1

Accepted Solution

by:
Moondancer earned 0 total points
ID: 6309661
Points were refunded to you, asselins.  Unfortunately, awards cannot be granted to the person asking the question, but having refunded your points, will move this to the PAQ so others may find the value herein.

Moondancer
Community Support Moderator @ Experts Exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

3 Experts available now in Live!

Get 1:1 Help Now