CGI中使用双缓冲遇到问题
关于Invalidate的使用 刚学C#
函数好像是指定某一区域无效,可我用下面代码 鼠标拖动会闪烁 这是为什么?
为什么我重绘改变的区域 会一直闪 而重绘非常小的一块 却看起来正常呢
MFC的Invalidate BOOL参数是指定是否先用背景填充区域 False直接覆盖 而C#没有?! 跟这有关吗?
项目里 我测出是对话框背景先重绘了次 这是为什么呢?
新手求解 OTL
Rectangle rc;
public Form1()
{
InitializeComponent();
rc = new Rectangle(5, 5, 0, 0);
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
BufferedGraphicsContext current = BufferedGraphicsManager.Current;
BufferedGraphics bg;
bg = current.Allocate(this.CreateGraphics(), this.DisplayRectangle);
Graphics g = bg.Graphics;
g.Clear(Color.LightGray);
Brush mybush = new SolidBrush(Color.Black);
g.FillRectangle(mybush, new Rectangle(0, 0, 400, 400));
Brush mybush2 = new SolidBrush(Color.Red);
g.FillRectangle(mybush2, rc);
bg.Render();
g.Dispose();
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
rc.Width = e.X;
rc.Height = e.Y;
this.Invalidate(rc,true);
//this.Invalidate(new Rectangle(0, 0, 5, 5), true); //上面换成这行效果还好
}