Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Screen flicker issue

Tags:

c#

winforms

I've got an issue where some computers (rarely) start to flicker when using our application. I found some odd code in the main form of our app:

    protected override CreateParams CreateParams
    {
        get
        {                
            var cp = base.CreateParams;
            cp.ExStyle |= 0x02000000;//composite window. Composite windows do not render/flickr when controls are born.  This speeds up loading.
            return cp;
        }
    }

The code appears to be sourced from an online source where they warn:

You should be aware of the fact, though, that this only works in environments where all control painting(within the hierarchy) is done within WM_PAINT. Applications using other/asynchronous means of rendering into a control within the hierarchy will likely have theirs problems with this solution causing unwanted behavior.

What exactly is WM_PAINT? Do they mean all controls need to be painted via win32 API calls or is this what happens normally in a Load event?

There's a note saying the code was added to reduce a bug report regarding flicker...I just wonder if they threw the baby out with the bathwater on this one.

like image 320
P.Brian.Mackey Avatar asked Jun 11 '26 04:06

P.Brian.Mackey


1 Answers

Try using DoubleBuffered = true;

like image 60
vbtheory Avatar answered Jun 20 '26 09:06

vbtheory



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!