Deciding when a tooltip appears

I have created an ownerdrawn button and would like to be
able to specify that a tooltip will appear only when the
cursor is within a specific region in the button. I managed
to control when the tooltip shows by overriding WM_NCHITTEST
but I don't know how to force the tip to pop, when the mouse
exits the region (I tried overriding WM_TOOLHITTEST in the
parent container -CView derived- to no avail). Any pointers?
alparAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kburns102197Commented:
Did you first overide CToolTipCtrl and add member functions that take advange of the fact that a tooltip control can do its own subclassing?
A tooltip control has to be able to see the mouse messages a tool receives so it know when to display the tooltip.  This works great if your pointer to the window (eg pWnd) points to top level window or a dialog box because the messages can be forwarded to the message handlers in the window or dialog class using CToolCtrl::RelayEvent. Here is the rub, if pWnd points to a child window control (like yopur ownere drawn button), you have to resort to window subclassing (or some other method) in order to see the mouse messages going to the window and relay them to the tooltip control.  You must add this capability on your own.

I use Prosise's technique and add a subclassing feature to my devrive class. (the new functions are AddWindowToo(CWnd*, LPCTSTR) and AddRectTool(CWnd*,LPCTSTR, LPCRECT, UNIT)  ) that set up a TOOLINFO structure and calls SendMessage( );

Creating a tool from a child window control just requires the call m_ctlName.AddWindowTool(pWnd,"This is your custom Button"); or you the AddRectTool call from a rectange in a window.  Hope this helps.. Let me know if you need more details
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
alparAuthor Commented:
Thanks for the assistance, but unfortunately I cannot derive
from CToolTipCtrl in order to solve my problem. Let me be more
specific:
I am using a CScrollView derived class, for which I have issued
'EnableToolTips'. This along with the 'TTN_NEEDTEXT' handler
work fine in all cases but a very specific one; I have created
an owner-drawn button, for which I would like to be able to
produce two different tooltips, depending on where on the button
the mouse cursor is. This, I think, would mean to be able to
'tell' the tooltip control used internally by CWnd's that they
should pop, when the cursor exited a known region on the button.
By overriding 'OnNCHitTest' I have managed to not allow the tip
to appear before the mouse cursor enters one of the two areas.
However, once the tip appears, I cannot make it 'go away',
because, I think, once it is shown it uses the window rectangle
internally to decide if it is still within valid area. I tried
to change that by overriding 'OnToolHitTest' at the view class
and from in there sending a message to the button, which should
decide itself if the point is within it. But this doesn't seem
to work. Could you suggest anything further, given the above
constraints?
0
alparAuthor Commented:
Sorry about messing the answer grading, but I am very new at
this. Am I not going to get another chance at giving you points?
If that is the case, accept my apologies, because you really
did answer the question I asked in the first place (although
it was not the question I should have asked obviously!)

Alex
0
kburns102197Commented:
Alex, Let me see the implementation of classes you have overidded & I will try to offer futher assistance. Provide as much detail as possible.. Don't worry about the points..its no big deal...kburns
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.