C# solves the dynamic display control flicker, so that Windows Forms enables double buffering on all forms and its child controls.

 There is such a Windows style in the SDK header file: WS_EX_COMPOSITED, this style enables Windows Forms to enable double buffering on all forms and its child controls.

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

 

 

What's said on the Internet is wrong.

        public Form1()
        {
            InitializeComponent();
            base.SetStyle(
            ControlStyles.OptimizedDoubleBuffer
            | ControlStyles.ResizeRedraw
            | ControlStyles.Selectable
            | ControlStyles.AllPaintingInWmPaint // 禁止擦除背景.
            | ControlStyles.UserPaint
            | ControlStyles.SupportsTransparentBackColor
            | ControlStyles.DoubleBuffer  // 双缓冲
            ,true);
        }

 

 

Guess you like

Origin blog.csdn.net/chenhao0568/article/details/107746845