BUG: MFC ActiveX Controls Paint Incorrectly when Scrolling the HTML PageID: Q233391
|
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.
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.
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.
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
Windowless controls do not experience any painting problems as a result of this bug.
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: June 11, 1999