双缓冲带面板 [英] Double buffering with Panel

查看:124
本文介绍了双缓冲带面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

双缓冲的整形式可以通过设置AllPaintingInWmPaint,UserPaint和DoubleBuffer的ControlStyles的值设置为真(this.SetStyle(ControlStyles.AllPaintingInWmPaint完成| ControlStyles.UserPaint | ControlStyles.DoubleBuffer,真))。

Double buffering the whole form can be done by setting the value of the "AllPaintingInWmPaint", "UserPaint" and "DoubleBuffer" ControlStyles to "true" (this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true)).

但是,这不能用System.Windows.Forms.Panel发生,因为类不允许我这样做。我找到了一个解决方案: http://bytes.com /主题/升C /答案/ 267635双缓冲面板控制。我也试过这样:的WinForms双缓冲的。这是laggy,即使当它在一个小拉用,我有我使用的形式和其他的东西了一些自定义的资源,因为这些我不会把整个表格到一个绘图。而第二个似乎引起问题。是否有其他方法来做到这一点?

But this can't happen with a System.Windows.Forms.Panel because the class doesn't allow me to do so. I have found one solution: http://bytes.com/topic/c-sharp/answers/267635-double-buffering-panel-control . I have also tried this: Winforms Double Buffering . It's laggy, even when it's used on a small drawing, I have some custom resources that I'm using in the form and other things because of which I won't turn the whole form into one drawing. And the second one seems to cause problems. Are there other ways to do that?

我问这个,因为我不想在面板上绘制调整大小窗体时闪烁所有的时间。如果有摆脱不双缓冲闪烁的方式,我会很高兴地知道。

I'm asking this because I don't want the drawing on the panel to flash all the time when the form is being resized. If there is a way to get rid of the flashing without double buffering, I'll be happy to know.

推荐答案

使用一个图片,如果你不需要滚动支持,这是双缓冲默认情况下。获得双缓冲滚动面板是很容易的:

Use a PictureBox if you don't need scrolling support, it is double-buffered by default. Getting a double-buffered scrollable panel is easy enough:

using System;
using System.Windows.Forms;

class MyPanel : Panel {
    public MyPanel() {
        this.DoubleBuffered = true;
        this.ResizeRedraw = true;
    }
}

该ResizeRedraw分配燮presses的容器控件一幅画的优化。你需要这个,如果你在面板上做任何绘画。没有它,画涂片当调整面板。

The ResizeRedraw assignment suppresses a painting optimization for container controls. You'll need this if you do any painting in the panel. Without it, the painting smears when you resize the panel.

双缓冲实际上使绘画更慢。它可以具有被稍后绘制在控制的效果。他们正在填补之前离开孔可以是一段时间可见的,也被看作是忽悠。你会发现针对<一个效果反制措施href=\"http://stackoverflow.com/questions/2612487/how-to-fix-the-flickering-in-user-controls/2613272#2613272\">this回答。

Double-buffering actually makes painting slower. Which can have an effect on controls that are drawn later. The hole they leave before being filled may be visible for a while, also perceived as flicker. You'll find counter-measures against the effect in this answer.

这篇关于双缓冲带面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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