在winforms应用程序中,我使用了一个名为panel的用户控件,并在此面板上进行绘图。但是,我已经使用了双缓冲
public Panel()
{
//double-buffering
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.ResizeRedraw, true);
}但是,当我填充屏幕上的任何形状时,屏幕仍会闪烁。
此外,我正在进行一些计算,计算要在Paint()中填充的区域。
提前谢谢。
发布于 2012-12-13 22:14:06
我不知道这是否有用。但是当我使用Invalidate方法和OnPaint事件而不是直接使用Paint (DoubleBuffering = true)时,我没有看到任何闪烁:
public partial class Form1 : Form
{
private Graphics g = null;
private Pen z = new Pen(new SolidBrush(Color.Blue));
public Form1()
{
InitializeComponent();
g = CreateGraphics();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawLine(z, p, p2);
}
private Point p = new Point();
private Point p2 = new Point();
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
p = e.Location;
p2 = e.Location;
Invalidate();
}
}https://stackoverflow.com/questions/13855108
复制相似问题