Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Hiding tooltip

Posted on 1997-05-26
12
Medium Priority
?
627 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 210 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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
 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses

971 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