Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WS_EX_COMPOSITED causes entire app to flicker/shimmer when tab control has too many tabs

Tags:

c#

winforms

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.

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");
    }

I'm running win7 if that matters.

like image 293
user1902192 Avatar asked Dec 13 '12 20:12

user1902192


1 Answers

Have a look at the answer to this question flicker free tab control with WS_EX_COMPOSITED

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

like image 129
Mathew Crothers Avatar answered Nov 14 '22 22:11

Mathew Crothers