BUG: MFC ActiveX Controls Paint Incorrectly when Scrolling the HTML Page

ID: Q233391


The information in this article applies to:
  • Microsoft Internet Explorer (Programming) version 5.0
  • The Microsoft Foundation Classes (MFC), included with:
    • Microsoft Visual Studio 6.0 sp1, sp2, sp3


SYMPTOMS

An MFC-based windowed ActiveX control on an HTML page paints incorrectly when you scroll the HTML page in the browser. The control appears distorted, showing successively larger bands at the bottom or top as it moves off the visible portion of the HTML page.


CAUSE

A performance enhancement was added to Internet Explorer 5 to improve the rendering of windowed ActiveX controls by manipulating the available window and clip regions for the control's window. When this code works on MFC controls, portions of the control's windows are invalidated but outside the clip region for the window. These regions are distorted and painting in OnDraw is clipped away from drawing over the top of them.


RESOLUTION

To solve this problem, add an OnPaint handler for the WM_PAINT message to the COleControl-derived class. In the OnPaint handler, reset the window region for the control:


void CWindowedCtrl::OnPaint() 
{
   CPaintDC dc(this); // device context for painting
	
   int cliprgnret;
   CRect rcClientRgn;
   HRGN hrgnClipOut;

   GetOuterWindow()->GetClientRect(&rcClientRgn);
   hrgnClipOut = ::CreateRectRgn(rcClientRgn.left, rcClientRgn.top,
                                rcClientRgn.right, rcClientRgn.bottom);
   cliprgnret = ::SetWindowRgn(GetOuterWindow()->m_hWnd, hrgnClipOut,
                               TRUE);

   COleControl::OnPaint(&dc);
} 
This code results in some flicker in the control. Unfortunately, this effect is not preventable.


STATUS

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


MORE INFORMATION

Windowless controls do not experience any painting problems as a result of this bug.

© Microsoft Corporation 1999, All Rights Reserved.
Contributions by Jason Strayer, Microsoft Corporation

Additional query words:

Keywords : kbActiveX kbCtrl kbCtrlCreate kbMFC kbVC600bug kbGrpInet kbIE500bug
Version : WINDOWS:5.0,6.0 sp1, sp2, sp3; winnt:
Platform : WINDOWS winnt
Issue type : kbbug


Last Reviewed: November 20, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.