本文介绍了WS_EX_COMOSPOSITED会使整个应用程序闪烁/闪烁当标签控件有太多标签时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了解决闪烁问题,我在 winforms 应用程序中使用了 WS_EX_COMPOSITED.这非常有效,直到选项卡控件获得如此多的选项卡以创建滚动箭头".在这一点上,我的整个应用程序看起来像是在不断地重绘,到处都在闪烁.

To solve a flickering issue, I resorted to using WS_EX_COMPOSITED in a winforms app. This works perfectly until a tab control gains so many tabs that it creates the "Scroll arrows." At this point, my entire application looks like its redrawing constantly with shimmering and flickering everywhere.

为了看看它是否只是我的应用程序,我编写了一个简单的 winforms 程序来测试它.它包含的只是一个带有添加选项卡的按钮的选项卡控件,其上的表单启用了 WS_EX_COMPOSITED... 果然,当我单击添加按钮并出现滚动箭头时会发生闪烁.

To see if it was just my app, I wrote a simple winforms program to test it. All it contains is a tab control with a button that adds a tab, and the form its on has WS_EX_COMPOSITED enabled... And sure enough, flickering happens when I click the add button and the scroll arrows appear.

多行选项卡控件修复了这个问题,但我在应用程序中没有空间来使用它.我的测试应用程序的代码非常简单......只是添加了一个标签页和一个按钮,然后在表单中:

Multiline tab control fixes this, but I don't have room in the app to use that. The code is really simple for my test app... Just added a tab page an a button, then in the form did:

        protected override CreateParams CreateParams
    {
        get
        {
            CreateParams cp = base.CreateParams;
            cp.ExStyle |= 0x02000000;  // Turn on WS_EX_COMPOSITED
            return cp;
        }
    }

    private void button1_Click(object sender, EventArgs e)
    {
        this.tabControl1.TabPages.Add("SomeTab");
    }

如果重要的话,我正在运行 win7.

I'm running win7 if that matters.

推荐答案

看看这个问题的答案 WS_EX_COMPOSITED 的无闪烁标签控制

可能需要一点时间来解决,但应该会有所帮助.

May take a bit to work around but it should help.

这篇关于WS_EX_COMOSPOSITED会使整个应用程序闪烁/闪烁当标签控件有太多标签时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 02:28