我怎么双重缓冲在C#中的面板? [英] How do I double buffer a Panel in C#?

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

问题描述

我有上有一个轮盘赌的面板上,我需要加倍缓冲面板,使其停止闪烁。谁能帮我?

I have a panel that has a roulette wheel on it, and I need to double buffer the panel, so that it stops flickering. Can anyone help me out?

〜T-福克斯

编辑:

是的,我已经试过了。

panel1.doublebuffered不存在,只有this.doublebuffered。而且我也不需要缓冲的形式,只是面板。

panel1.doublebuffered does not exist, only this.doublebuffered. And I don't need to buffer the Form, just the Panel.

推荐答案

您需要从面板或图片框派生。

You need to derive from Panel or PictureBox.

有分歧这取决于您选择如何启用缓冲。

There are ramifications to this depending on how you choose to enable the buffering.

如果您设置this.DoubleBuffer标志,那么你应该没问题。

If you set the this.DoubleBuffer flag then you should be ok.

如果您手动更新的样式,那么你必须自己画的形式WM_PAINT。

If you manually update the styles then you have to paint the form yourself in WM_PAINT.

如果你真的觉得雄心勃勃可以保持并绘制自己的后台缓冲区为位图。

If you really feel ambitious you can maintain and draw your own back buffer as a Bitmap.


using System.Windows.Forms;

public class MyDisplay : Panel
{
    public MyDisplay()
    {
        this.DoubleBuffered = true;

        // or

        SetStyle(ControlStyles.AllPaintingInWmPaint, true);
        SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
        UpdateStyles();
    }
}

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

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