how to stop flickering C# winforms

前端 未结 16 2277
故里飘歌
故里飘歌 2020-11-28 04:16

I have a program that is essentially like a paint application. However, my program has some flickering issues. I have the following line in my code (which should get rid of

16条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-28 04:36

    Copy and paste this into your project

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

    This enables double-buffering for all controls from the form level down, otherwise double buffering needs to be individually enabled for each one... you may want to fine tune double bufferring after this because blanketed double buffering may give unwanted side effects.

提交回复
热议问题