如何阻止OnPaint闪烁 [英] How to stop OnPaint flickers

查看:291
本文介绍了如何阻止OnPaint闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



让create class继承System.Windows.Forms.Control来覆盖他的OnPaint。怀疑是这样,在控制器上拖动一个对话框,导致它出现恼人的闪烁和未完成,可以放在OnPaint上的东西会停止这个吗?

Hello,

Have create class inherits System.Windows.Forms.Control to override his "OnPaint". Doubt is this, upon dragged across the control a dialog, causes it to appear annoying flicker and unfinished, what can be put on "OnPaint" stops this?

推荐答案

它取决于渲染的内容,但在大多数情况下,简单的技术可以有效地减少或消除闪烁:双重缓冲。



请参阅物业 System.Windows.Forms.Control.DoubleBuffered

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.doublebuffered.aspx [ ^ ]。



你也可以使用类System.Drawing.BufferedGraphics

http://msdn.microsoft.com/en-us/library/system.drawing.bufferedgraphics.aspx [ ^ ]。



参见: http://msdn.microsoft.com/en-us/library/system.windows。 forms.controlstyles.aspx [ ^ ]。



通常,如果你设置双缓冲,它会立即起作用。这是因为它将渲染图像缓存在位图中,该位图一次从上到下绘制。图像的中间变化收集在一个图像中,不显示。



-SA
It depends on what is going on with your rendering, but in majority of cases, on simple techniques effectively reduce or eliminate flicker: double buffering.

Please see the property System.Windows.Forms.Control.DoubleBuffered:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.doublebuffered.aspx[^].

You can also use the class System.Drawing.BufferedGraphics:
http://msdn.microsoft.com/en-us/library/system.drawing.bufferedgraphics.aspx[^].

See also: http://msdn.microsoft.com/en-us/library/system.windows.forms.controlstyles.aspx[^].

Usually, if you set up double buffering, it helps immediately. This is because it buffers the rendered image in a bitmap, which is drawn top to down at once. Intermediate changes in image are collected in one image and are not shown.

—SA


谢谢你的解决方案DoubleBuffered提供了帮助
Thanks for solution. DoubleBuffered made helpful


这篇关于如何阻止OnPaint闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆