winform窗体闪烁问题解决方式
1、使用窗体双缓冲
SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true);
UpdateStyles();
窗体的DoubleBuffered 指示是否对控件进行双缓存处理。
2、使用CreateParams的使用解决闪屏问题
#region 解决添加背景图片时闪屏的问题 protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED if (this.IsXpOr2003 == true) { cp.ExStyle |= 0x00080000; // Turn on WS_EX_LAYERED this.Opacity = 1; } return cp; } } /// <summary> /// 防止闪烁 /// </summary> private Boolean IsXpOr2003 { get { OperatingSystem os = Environment.OSVersion; Version vs = os.Version; if (os.Platform == PlatformID.Win32NT) if ((vs.Major == 5) && (vs.Minor != 0)) return true; else return false; else return false; } } #endregion
标签:return,CreateParams,vs,窗体,ControlStyles,cp,闪烁,winform From: https://www.cnblogs.com/1175429393wljblog/p/17633252.html