Microsoft KB Archive/216461

= BUG: Toolbar Covers Document in MFC ActiveX Document Container =

Article ID: 216461

Article Last Modified on 11/21/2006

-

APPLIES TO

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

 Microsoft Visual C++ 6.0 Professional Edition

 Microsoft Visual C++ 6.0 Standard Edition 

-

<div class="notice_section">

This article was previously published under Q216461

<div class="symptoms_section">

SYMPTOMS
If you create an MFC AppWizard-generated ActiveX document container, insert a Microsoft Word document or Excel Spreadsheet, and move a toolbar from the top to the left side of the window, without dragging the toolbar through the main window, the toolbar will cover part of the document.

<div class="cause_section">

CAUSE
This problem is caused by CFrameWnd::RecalcLayout not being called when the toolbar is docked on the left side of the frame window.

<div class="resolution_section">

RESOLUTION
Force CFrameWnd::RecalcLayout to be called from the OnShowControlBars function of the COleDocObjectItem-derived class. Perform the following steps to do this:

<ol>  Add the declaration of OnShowControlBars to the COleDocObjectItem-derived class, which is declared in the Cntritem.h file: virtual BOOL OnShowControlBars(CFrameWnd*, BOOL); </li>  Implement OnShowControlBars of the COleDocObjectItem-derived class in theCntritem.cpp file: BOOL CAXContainerCntrItem::OnShowControlBars(CFrameWnd* pFrameWnd, BOOL bShow) {   BOOL bResult = COleDocObjectItem::OnShowControlBars(pFrameWnd, bShow); if(pFrameWnd->m_nIdleFlags & CFrameWnd::idleLayout) pFrameWnd->RecalcLayout;

return bResult;

}                   </li></ol>

<div class="status_section">

STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

<div class="moreinformation_section">

Steps to Reproduce Behavior

 * 1) Create a new SDI or MDI AppWizard project and select ActiveX document container support.
 * 2) On the Build menu, click Run.
 * 3) On the Edit menu, click Insert Object.
 * 4) Select Microsoft Word Document.
 * 5) Maximize the MDI Child window (only for MDI applications).
 * 6) On the View menu, click Normal.
 * 7) Grab the toolbar right above the document, and drag it to the left docking position without dragging the cursor into the main window.

<div class="references_section">