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.

相关文章推荐

swiper中加了autoheight后swiper-wrapper的高度显示不正确的解决方法

前段时间在做项目的时候用到了swiper来做Tab切换,但是却遇到了下面的问题: swiper中加了autoheight后swiper-wrapper的高度显示不正确, function chan...

"由于应用程序配置不正确,应用程序未能启动。重新安装应用程序可能会纠正这个问题"解决方法

← win32 mfc命名规范ExitWindowsEx 关机、重启、注销的编程实现 →由于应用程序配置不正确,应用程序未能启动。重新安装应用程序可能会纠正这个问题。发表于2010-06-04由tun...

Android中发送网络请求时参数为中文,导致请求的结果不正确的解决方法

前几天做项目的时候,遇到一个问题。在我们客户端给服务器发送请求的时候,获取不到响应的结果。然后我就向我们这个项目的技术总监提了这个问题。 技术总监说,你再发一次请求试试看,我去控制台看看是什么原因。一...

VC运行时库与应用程序配置不正确,程序无法启动”的解决方法资料收集

转:  http://dearymz.blog.163.com/blog/static/205657420096675044722/  VC项目属性 →配置属性→C/C++→代码生成→运行时库 可以...

Android4.4以上从图库选择图片返回的路径不正确解决方法

android 4.4系统以前,选择图片,获取图片路径代码如下: 1 2 3 4 5 //访问图库 Intent inte...

U8v10.1 出纳票据打印在 Nantian PR2E上打印不正确问题的解决方法

以前使用拥有票据通的用户都会配置 四通公司的票据打印机(虽然已经倒闭多年,但是产品线依然存在不能不称之为奇迹)。但是到了21世纪,U8v10.1横空出世之后,出纳整合了票据通功能之后问题也就随之而来。...
  • ewalker
  • ewalker
  • 2012年04月12日 20:56
  • 2111

由于数据库ojdbc14.jar版本不正确导致ORA-01461问题的解决方法

今天在部署主站的过程中,出现了由于ojdbc14.jar版本不正确导致了ORA-01461问题,现将处理过程简单记录一下: 1、应用程序报错信息如下: 2013-04-03 14:34:54,67...

应用程序无法启动,因为应用程序的并行配置不正确。有关详细信息,请参阅应用程序事件日志,或使用命令行sxstrace.exe工具。解决方法

应用程序无法启动,因为应用程序的并行配置不正确。有关详细信息,请参阅应用程序事件日志,或使用命令行sxstrace.exe工具。解决方法...

easyUI的列表控件(datagrid)日期列不能正确显示的解决方法

一、遇见的问题         EasyUI是一套比较轻巧易用的Jquery控件,在EasyUI中,我认为,他的表格 , 做的堪称完美。但是,美中不足的是,在使用过程中遇到一个问题,它的列表控件——...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:mfc控件在ie里面显示不正确的解决方法
举报原因:
原因补充:

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