mfc控件在ie里面显示不正确的解决方法

转载 2006年05月23日 13:16:00

FIX: MFC ActiveX controls paint incorrectly when scrolling the HTML page

Article ID : 233391
Last Review : February 1, 2005
Revision : 4.0
This article was previously published under Q233391

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.

In versions of Microsoft Internet Explorer later than version 5, the control may paint correctly. However, child windows on the control still experience the banding effects while scrolling.

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 operates on MFC controls, portions of the control's window outside the clip region are invalidated. Because the control's OnDraw cannot draw outside the clip region, these areas show stripes of the background color.

RESOLUTION

To resolve this problem, upgrade clients to version 5.01 or later of Internet Explorer.

Note A change was made in Internet Explorer to fix the problem that is described in the following Microsoft Knowledge Base (KB) article:
307978 (http://support.microsoft.com/kb/307978/) FIX: MFC controls in overlapped IFRAMEs receive unnecessary WM_PAINT messages
However, this change reintroduced the problem in Internet Explorer 6 Service Pack 1.

WORKAROUND

To work around this problem, use one of the following methods:
Repaint the control when the cnscroll event fires, as in the following sample code.
<SCRIPT>
function workaround()
{
// "a" is the name of the control.
window.document.all.item("a").style.display = "none"
window.document.all.item("a").style.display = ""
}
</SCRIPT>
<BODY onscroll="workaround();">
If the control class is derived from the COleControl class, it implements a virtual method that is named OnSetObjectRects. You can override this method, as in the following sample code.
BOOL CmfcaxCtrl::OnSetObjectRects(LPCRECT lpRectPos, LPCRECT lpRectClip) 
{ return TRUE; 
}
Use ATL instead of MFC to develop the ActiveX control.
Unfortunately, MFC controls that contain child windows will still have painting problems in Internet Explorer. You can resolve these problems by forcing a redraw on all the child windows during handling of the OnPaint message. To do this, you must add a message map entry for WM_PAINT to the COleControl-derived class. In the OnPaint handler, use code that is similar to the following.
// NUMBER_OF_CHILDREN is predefined as the number of child windows
// that are hosted on this control

// m_Children is a member variable of the CWindowedCtrl class that
// stores an array of CWnd references to the child windows on the control.

void CWindowedCtrl::OnPaint()
{
   CPaintDC dc(this); // device context for painting<BR/>

   for(int i = 0 ; i < NUMBER_OF_CHILDREN ; i++)
   {
      m_Children[i].RedrawWindow(NULL,NULL,RDW_INVALIDATE | RDW_FRAME);   
   }

   COleControl::OnPaint(&dc);
}

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section. This problem was corrected in Internet Explorer 5.01. This problem was reintroduced in Internet Explorer 6 Service Pack 1.

MORE INFORMATION

This bug does not cause any painting problems for windowless controls.

MFC程序添加Web浏览器控件(IE控件)

MFC程序添加Web浏览器控件(IE控件)       1. 新建一个基于对话框的MFC程序   这里使用VS2010建立一个MFC Application,种类选择基于对话框Dialog...
  • u011763045
  • u011763045
  • 2013年11月05日 00:17
  • 8258

MFC:TabCtrl使用教程

示例下载一、新建基于对话框的MFC程序TabCtrl_Demo添加一个TabCtrl控件,绑定变量:CTabCtrl m_tabCtrl。二、创建Tab标签对应的子对话框插入3个子对话框,并设置属性S...
  • wangyao1052
  • wangyao1052
  • 2015年05月16日 00:53
  • 3118

vs2010开发activex(MFC)控件/ie插件(一)

vs2010制作基于mfc的ie插件
  • yhhyhhyhhyhh
  • yhhyhhyhhyhh
  • 2016年03月02日 20:35
  • 3813

MFC在对话框中添加了一个richedit控件,窗口就不显示了。

在对话框中添加了一个richedit控件,对话框就不显示了 郁闷,我试图弹出一个对话框,步骤如下: 1.建立了一个对话框资源的模板 2.双击模板建立对应的类 3.包含头文件 4,弹出对话框,...
  • u014683488
  • u014683488
  • 2015年02月28日 22:33
  • 977

【OpenCV+MFC】之一:在Picture控件显示图像

前几天发了一个文章,是MFC控件上显示BMP图片,没有使用OpenCV,缺点是只能打开BMP文件(点击打开链接)。今天为了将方法改进,看了一些资料,经过自己的总结,得到了在Picture控件上显示Op...
  • bcniber
  • bcniber
  • 2014年03月27日 22:24
  • 2717

[ MFC ] 对话框动态控件的创建 在Picture Control控件上显示图片 [大三TJB_708]

VS2012MFC 应用程序 1 MFC对话框之上的动态控件的创建 在对话框上的控件是MFC类的一个具体对象,其对应的变量内包含了类的数据成员和函数成员。当在对话框之上使用静态控件时,可以根据类...
  • misskissC
  • misskissC
  • 2014年05月13日 19:50
  • 47465

在VS中通过MFC图片控件显示视频

在opencv2.0以上版本之后,就没有对CvvImage类的使用,所以在有VS编程实现MFC显示视频或者图像时候,必须找到CvvImage类头文件,以及源文件加入到编程的文件中,并且添加到工程中去。...
  • poiiy333
  • poiiy333
  • 2013年05月13日 14:33
  • 1136

opencv Mat图像显示在MFC控件上,亲测有效。为原作者点赞!

opencv Mat图像显示在MFC控件上,亲测有效
  • melon1188
  • melon1188
  • 2017年03月09日 21:41
  • 1123

mfc中设置控件颜色

在MFC类库提供了CWnd::OnCtlColor函数,在工作框架的子窗口被重画时将调用该成员函数.因此可以重载WM_CTLCOLOR消息的响应函数.此函数的原型:   afx_msg HB...
  • echojiangyq
  • echojiangyq
  • 2014年04月23日 09:28
  • 3558

利用MFC的Picture控件显示和处理图像

在《OpenCV教程-基础篇》的2.8节中,所创建的MFC图像显示是直接放在对话框面板的左上角的,感觉不大美观。在MFC快速应用opencv一书中则是介绍用SDI(单文档界面)来显示图像,《A st...
  • fengqingbojing
  • fengqingbojing
  • 2016年02月27日 13:58
  • 1437
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:mfc控件在ie里面显示不正确的解决方法
举报原因:
原因补充:

(最多只允许输入30个字)