Solved

Hiding tooltip

Posted on 1997-05-26
12
619 Views
Last Modified: 2013-11-19
I'm showing a tooltip like window when the user moves the cursor over the client area. The tooltip is my own CWnd derived class, because I need to display multiline information.
I want the window to disappear when the cursor moves outside the client area. I tried using SetCapture, but I don't get any WM_MOUSEMOVE messages when the cursor moves outside the client area.
The toolbar manages to hide it's tooltip when the cursor moves outside the toolbar, so it should be possible I guess. If you've got some pointers on how to solve this, it would be great.
0
Comment
Question by:roar
  • 6
  • 5
12 Comments
 
LVL 4

Accepted Solution

by:
AVaulin earned 70 total points
ID: 1301805
You must handle WM_NCHITTEST message in all your windows. It's sent to a window when the cursor moves, or when a mouse button is pressed or released. So if this message sent to parent window you must hide tooltip.
0
 

Author Comment

by:roar
ID: 1301806
Isn't there some other way to do this? I have many windows, some of them are third party libraries. It's going to be kind of messy to insert code to handle this in all of them. Besides, all the other windows don't have to explicitly notify the toolbar that the cursor has moved outside the the toolbar. How does the toolbar know that the cursor has moved?
0
 
LVL 4

Expert Comment

by:AVaulin
ID: 1301807
There is also one way to hide tooltips: handle TTN_POP message (I hope you use TTN_NEEDTEXT message to show tooltips). But there is little problem: window receive TTN_POP message before mouse cursor leave window's area. See for example how tooltip hides inside VC.
0
 

Author Comment

by:roar
ID: 1301808
I don't use TTN_NEEDTEXT , I just show it in OnMouseMove. Is it better to use TTN_NEEDTEXT ?
You mentioned WM_NCHITTEST , will it work to make the window that displays the tooltips capture the mouse and handle WM_NCHITTEST ? Then check in the WM_NCHITTEST handler if cursor moves outside the window, and hide tooltip if it does?

0
 
LVL 4

Expert Comment

by:AVaulin
ID: 1301809
Any window receive WM_NCHITTEST when mouse cursor is inside window area. When cursor leave window area another window receive this message. So all your windows must handle this message to show and hide tooltip (include buttons, statics etc). This way is very laborious.
I propose another way. You must use EnableToolTips() method for your View class (after creating) and handle TTN_NEEDTEXT message to show tooltip and TTN_POP to hide it.
0
 

Author Comment

by:roar
ID: 1301810
I found a sample at
http://ourworld.compuserve.com/homepages/mrconway/tooltip.htm
that shows how to use the tooltips in a view as you describe. The problem is that I need to display multiple line of information. The default tooltip window will not do that, so I need to use my own class instead. I am able to display both the single line tooltip and my own multiline tooltip simultaneously, but that is obviously not what I want.
If I don't give the tooltip any text in the TTN_NEEDTEXT handler, only my multiline tooltip window shows, but then I don't get the TTN_POP notification either. And then I'm back to the original problem with removing the tooltip. Is it possible to derive a class from CToolTipCtrl, and make MFC call that to display tooltips? How do I do that?
0
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.

 
LVL 4

Expert Comment

by:AVaulin
ID: 1301811
So I see only 1 very laborious way: using WM_NCHITTEST message handling for all windows. You may reject my answer. May be anybody can say more (but I doubt that no).
Good luck.
0
 

Author Comment

by:roar
ID: 1301812
Alright, thank you for fast and informative answers. It would be interesting to see a comment from Mike Blaszczak on this issue, could you pass it on to him please? (Is it possible to solve this by subclassing or by using undocumented MFC?)
0
 
LVL 4

Expert Comment

by:AVaulin
ID: 1301813
I can't pass question to anybody. To do this you must reject my answer. This is only way for your question to restore status to "Questions Awaiting Answers".
Moreover I don't know who is Mike Blaszczak. Sorry.
0
 
LVL 3

Expert Comment

by:vinniew
ID: 1301814
You're right.  Subclass your client window and handle the WM_NCHITTEST for THAT window and ONLY that window.
0
 

Author Comment

by:roar
ID: 1301815
When you say client window, do you mean the tooltip window or the view? What should the WM_NCHITTEST handler look like?

0
 

Author Comment

by:roar
ID: 1301816


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

Title # Comments Views Activity
Strange date stored 22 106
Unix / Linux grid computing 5 147
Replacement selected text 2 58
Dell Alienware Graphics Amplifier Driver for non-Alienware systems 18 192
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

910 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

25 Experts available now in Live!

Get 1:1 Help Now