Microsoft KB Archive/247382

= PRB: ToolTips for Controls in ActiveX Document Server Are Hidden by the ActiveX Document Container =

Article ID: 247382

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 5.0 Enterprise Edition

 Microsoft Visual C++ 6.0 Enterprise Edition

 Microsoft Visual C++ 5.0 Professional Edition

 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 Q247382

<div class="symptoms_section">

SYMPTOMS
To add ToolTips for controls in the ActiveX Document server, you can use the Microsoft Foundation Classes (MFC) default implementation by calling the EnableToolTips function, which works correctly. However, for more flexible functionality of the ToolTip, you can also use the CTooltipCtrl class to create your own ToolTip control object. If the ToolTips are created by using the CTooltipCtrl class, it is not shown in the ActiveX Document Container.

<div class="cause_section">

CAUSE
When the user calls the server from the document container, the main frame window is the container's frame window, (that means that the window procedure is a different window procedure). Thus, it mixes up the z-order of the windows. However, although the ToolTip window is actually being shown, it is hidden behind the window of the server.

<div class="resolution_section">

RESOLUTION
To work around the problem, set the z-order of the ToolTips to the topmost level after creating the ToolTips. This sample code illustrates the workaround: void CTestView::OnInitialUpdate {   CFormView::OnInitialUpdate; ResizeParentToFit;

CButton * mButton = (CButton *)GetDlgItem(IDC_BUTTON1);

if( !m_tooltip.Create(this,TTS_ALWAYSTIP)) TRACE(_T("Unable to Create ToolTip")); else if( !m_tooltip.AddTool( mButton, "Show the tooltips")) TRACE(_T("Unable to add tip for the control window")); else {       m_tooltip.SetWindowPos(&wndTopMost,0,0,0,0,SWP_SHOWWINDOW|                                    SWP_NOSIZE |SWP_NOMOVE); m_tooltip.Activate(TRUE); }  }

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

Steps to Reproduce Behavior
<ol> Use the MFC AppWizard to generate an ActiveX Document Server application. That is, at step 3 of 6, under the category "What compound document support would you like to include?", select Full-server and check Active Document Server. At step 6, select CFormView as the base class of the view.</li> Add a button, IDC_BUTTON1, to the form view's resource template.</li>  Add a private member variable to the view class, as shown here: CToolTipCtrl m_tooltip; </li>  In the OnInitialUpdate function of the view class, insert the following code snippet to create the ToolTip for the button. CButton * mButton = (CButton *)GetDlgItem(IDC_BUTTON1);

if( !m_tooltip.Create(this,TTS_ALWAYSTIP)) TRACE(_T("Unable to Create ToolTip")); else if( !m_tooltip.AddTool( mButton, "Show the tooltips")) TRACE(_T("Unable to add tip for the control window")); else m_tooltip.Activate(TRUE); </li>  Override the PreTranslateMessage function of the view class and add the following code to it: if(pMsg->message== WM_LBUTTONDOWN ||  pMsg->message== WM_LBUTTONUP ||    pMsg->message== WM_MOUSEMOVE) m_tooltip.RelayEvent(pMsg); </li> Build the application and run it once as a stand alone application. Move the pointer over the button. Note that the ToolTip is shown correctly.</li> Now use the MFC AppWizard to generate an ActiveX Document Container application. That is, at step 3 of 6, under the category "What compound document support would you like to include?", select Container and check Active Document Container. Choose the default settings similar the other steps except exclude step 3.</li> Build and run the container application. Under the menu item select Edit and Insert New Object. Choose the name of your server from the Insert Object dialog box and click OK</li> Move the pointer over the button. Notice that the ToolTip is not visible.</li></ol>

Additional query words: CTooltipCtrl SetWindowPos

Keywords: kbactivedocs kbcmnctrls kbcontainer kbprb kbtooltip KB247382

-

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

© Microsoft Corporation. All rights reserved.