Microsoft KB Archive/143313

= FIX: CToolTipCtrl Stops Working After Dialog Is Displayed =

Article ID: 143313

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 4.0 Standard Edition

 Microsoft Visual C++ 4.1 Subscription

 Microsoft Visual C++ 4.2 Enterprise Edition

 Microsoft Visual C++ 5.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 6.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 4.2 Professional Edition</li></ul>

 Microsoft Visual C++ 5.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q143313

<div class="symptoms_section">

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.

<div class="cause_section">

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.

<div class="resolution_section">

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.

<div class="status_section">

STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

This problem was corrected in Microsoft Visual C++ .NET.

<div class="moreinformation_section">

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: kbVC400bug kbvc410bug kbvc420bug kbvc500bug kbvc600bug CToolTipCtrl DoModal

Keywords: kbbug kbfix kbnoupdate kbtooltip kbuidesign KB143313

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.