Solved

Hiding tooltip

Posted on 1997-05-26
12
624 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
[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
  • 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
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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses

636 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