首页 > Windows开发 > 详细

C#解决MDI窗体闪屏的方法

时间:2014-03-01 02:14:40      阅读:574      评论:0      收藏:0      [点我收藏+]

解决办法很easy:

以下代码块加在父窗体中的任意位置

protected override CreateParams CreateParams

{

get

{

CreateParams cp = base.CreateParams;

cp.ExStyle |= 0x02000000;

return cp;

}

}

原理很简单,引用以下原话:

 A form that has a lot of controls takes a long time to paint.  Especially the Button control in its default style is expensive.  Once you get over 50 controls, it starts getting noticeable.  The Form class paints its background first and leaves "holes" where the controls need to go.  Those holes are usually white, black when you use the Opacity or TransparencyKey property.  Then each control gets painted, filling in the holes.  The visual effect is ugly and there‘s no ready solution for it in Windows Forms.  Double-buffering can‘t solve it as it only works for a single control, not a composite set of controls. 

I discovered a new Windows style in the SDK header files, available for Windows XP and (presumably) Vista: WS_EX_COMPOSITED.  With that style turned on for your form, Windows XP does double-buffering on the form and all its child controls.  

C#解决MDI窗体闪屏的方法,布布扣,bubuko.com

C#解决MDI窗体闪屏的方法

原文:http://www.cnblogs.com/yzl050819/p/3573620.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!