Tooltips in CView disabled after showing dialog

My tooltips in a CView window works fine if I don't invoke any (modal) dialog. If I display a dialog, then the tooltips don't show any more until another new CView is displayed. There was a similar known bug in MFC tooltip handling. How do I fix this problem? I tried EnableToolTips in CView again to no effect. [To emphasize: I am referring to the tooltips in the CView controls, not on the toolbar.]
stevejobsAsked:
Who is Participating?
 
RONSLOWConnect With a Mentor Commented:
Here is the article (I think) .. but note that it says it does not apply when using EnableToolTips

Microsoft Knowledge Base
BUG: CToolTipCtrl Stops Working After Dialog Is Displayed
Last reviewed: June 26, 1997
Article ID: Q143313  
The information in this article applies to:
The Microsoft Foundation Classes (MFC) included with: Microsoft Visual C++, 32-bit Edition, versions 4.0, 4.1, 4.2, 5.0

SYMPTOMS

If you create a CToolTipCtrl and call AddTool() to activate it, it will work until you display a modal dialog box. For example, if on the Help menu, you click About to display the About box, and you then click OK to dismiss it, the CToolTipCtrl will not pop up anymore.

CAUSE

MFC is sending a WM_DISABLEMODAL to all of the frame's descendant windows when a modal dialog box pops up. The CToolTipCtrl responds to the WM_DISABLEMODAL by sending itself a TTM_ACTIVATE with a FALSE. This disables it. However, the CToolTipCtrl doesn't reactivate itself once the frame calls EnableWindow() for its descendants.

RESOLUTION

You should have a PreTranslateMessage() function where you are calling RelayEvent(). The workaround for this problem is to call Activate(TRUE) before the call to RelayEvent().

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

This is only a problem if you create your own CToolTipCtrl. Using EnableToolTips() does not have this problem.

Sample Code to Demonstrate Problem

   // m_pToolTip is a CToolTipCtrl *
   BOOL CTestView::PreTranslateMessage(MSG* pMsg)
   {
       switch(pMsg->message)
       {
           case WM_MOUSEMOVE:
           case WM_LBUTTONDOWN:
           case WM_LBUTTONUP:
           case WM_MBUTTONDOWN:
           case WM_MBUTTONUP:
           case WM_RBUTTONDOWN:
           case WM_RBUTTONUP:
               // This will reactivate the tooltip
               m_ToolTip.Activate (TRUE);
               m_ToolTip.RelayEvent (pMsg);
       }
       return CFormView::PreTranslateMessage(pMsg);
   }

   /* Compile options needed: default
   */
-----------------------------------------------------------------
Additional query words: CToolTipCtrl DoModal
Keywords : kbprg MfcUI vcbuglist400 vcbuglist500 kbbuglist
Technology : kbMfc
Version : 4.0 4.1 4.2 5.0
Platform : NT WINDOWS
Issue type : kbbug

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 26, 1997
©1997 Microsoft Corporation. All rights reserved. Legal Notices.

0
 
RONSLOWCommented:
How do you do your tooltips in the view class?  Do you use EnableToolTips() ?

0
 
RONSLOWCommented:
Do you mean that tooltips work.  The you display a (modal) dialog and CLOSE it, and the tooltips no longer work after that?

Or are you saying that they do not work WHILE the modal dialog is displayed?

What version of MC do you have?  Do you havethe latest service packs (SP3?)
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
stevejobsAuthor Commented:
Yes, I use EnableTooltips() when creating the CView window.
Yes, the tooltips work so long as I don't open any dialog. Once a dialog is opened (any dialog) and then closed and I go back to the CView window, tooltips don't appear again.
No, I am not saying they don't work while the dialog is displayed. I believe the dialog code somehow disable tooltips and I tried to reenable in CView but it didn't help.

I have Visual Studio C++ 5.0 and latest SP 3.
0
 
RONSLOWCommented:
What happens if you click on the view (to ensure it is the active window)?

It could be that after your dialog closes, your view is not active (perhaps the frame is active instead).

0
 
stevejobsAuthor Commented:
I sure do click on the view. In fact, if I create a new view (this is an MDI app), the new view window will have tooltips active while the old one doesn't.
0
 
RONSLOWCommented:
hmmm .. let me dwell on that for a while.
0
 
stevejobsAuthor Commented:
I've just rechecked and can confirm that the 'activeness' of a view window doesn't affect the tooltips display. A view window can be inactive and still have tooltips. It seems the dialog (in my case) disables the tooltips of its parent and I just want to be able to reactivate the tooltip function in the view parent!!!
I know it's just one line of code, but where?
0
 
RONSLOWCommented:
Actually, I remember reading something about a similar problem (of tooltips not being reactiveated).  It is a bug in the code .. I'll try to track it down for you.

0
 
RONSLOWCommented:
Are you doing anything with tooltips in the modal dialog?  Maybe that is having a similar effect?
0
 
stevejobsAuthor Commented:
RONSLOW:
You are marvellous. I suspected it was only one line of code and I tried the EnableToolTips while I should use the Activate(TRUE) statement.
Thank you!!! Bug is fixed.
0
 
RONSLOWCommented:
>You are marvellous

Glad to have my opinion of myself backed up :-)

And glad to help you.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.