?
Solved

Deciding when a tooltip appears

Posted on 1997-11-08
4
Medium Priority
?
593 Views
Last Modified: 2013-11-20
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?
0
Comment
Question by:alpar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
kburns102197 earned 150 total points
ID: 1309596
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
 

Author Comment

by:alpar
ID: 1309597
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
 

Author Comment

by:alpar
ID: 1309598
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
 
LVL 1

Expert Comment

by:kburns102197
ID: 1309599
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

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

762 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