Solved

Deciding when a tooltip appears

Posted on 1997-11-08
4
564 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need a Shell script to start a service checking the port 6 50
MFC Dialog 9 49
Login Script to Copy Folders 12 35
Need to retreive data from .TFS file exported by DVR 8 199
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

809 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