相关疑难解决方法(0)

如何修复用户控件中的闪烁

在我的应用程序中,我不断从一个控件移动到另一个控件.我创造了没有.用户控件,但在导航过程中我的控件闪烁.更新需要1或2秒.我试着设置这个

SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
or
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true); 
SetStyle(ControlStyles.DoubleBuffer, true);
Run Code Online (Sandbox Code Playgroud)

但它没有帮助......每个控件都有相同的背景图像和不同的控件.那么它的解决方案是什么..
谢谢.

c# user-controls flicker winforms

105
推荐指数
4
解决办法
9万
查看次数

如何停止闪烁C#winforms

我有一个基本上像绘图应用程序的程序.但是,我的程序有一些闪烁的问题.我的代码中有以下行(它应该摆脱闪烁 - 但不是):

this.SetStyle(ControlStyles.AllPaintingInWmPaint 
| ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
Run Code Online (Sandbox Code Playgroud)

我的代码(减去形状的超类和子类如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Paint
{
    public partial class Paint : Form
    {
        private Point startPoint;
        private Point endPoint;
        private Rectangle rect = new Rectangle();
        private Int32 brushThickness = 0;
        private Boolean drawSPaint = false;
        private List<Shapes> listOfShapes = new List<Shapes>();
        private Color currentColor;
        private Color currentBoarderColor;
        private Boolean IsShapeRectangle = false;
        private Boolean IsShapeCircle = false; …
Run Code Online (Sandbox Code Playgroud)

c# drawing

65
推荐指数
4
解决办法
9万
查看次数

通过双缓冲区减少闪烁:SetStyle与重写CreateParam

任何人都可以解释它们之间的区别和关系

SetStyle(ControlStyles.UserPaint |
         ControlStyles.AllPaintingInWmPaint |
         ControlStyles.DoubleBuffer, true)
Run Code Online (Sandbox Code Playgroud)

protected override CreateParams CreateParams
{
    get
    {
        CreateParams cp = base.CreateParams;
        cp.ExStyle |= 0x02000000;  // Turn on WS_EX_COMPOSITED
        return cp;
    }
}
Run Code Online (Sandbox Code Playgroud)

他们需要减少闪烁,但是何时以及如何正确使用它们?它们可以单独使用,还是必须成对使用,这是什么原因?

谢谢!

积分:

第一个代码片段是从MSDN页面引用的; 在如何修复用户控件中的闪烁中找到第二个代码片段,原始作者是@HansPassant.

c# flicker winforms

9
推荐指数
1
解决办法
4163
查看次数

标签 统计

c# ×3

flicker ×2

winforms ×2

drawing ×1

user-controls ×1