Solved

Deciding when a tooltip appears

Posted on 1997-11-08
4
574 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
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
kburns102197 earned 50 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Is it possible to combine several text files into one big one? (redhat v5 enterprise) 4 103
Decoding 32 bit binary streams 6 49
maxBlock challenge 30 142
sumHeights2  challenge 7 117
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

820 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