用C#的GDI+来绘图时按下alt后发现绘制的全没了(窗体应用)
private void field_MouseDown(object sender, MouseEventArgs e)//用来记录点击鼠标时的指针位置
{
//if (type == 2)
//{
Brush brush = new SolidBrush(Color.Blue);
Point[] pts_tmp = new Point[4];
pts_tmp[0] = new Point(40, 40);
pts_tmp[1] = new Point(80, 40);
pts_tmp[2] = new Point(80, 80);
pts_tmp[3] = new Point(40, 80);
fill(pts_tmp);
//}
}
其中fill如下:
private void fill(Point[] pts_tmp)
{
Brush brush = new SolidBrush(Color.Blue);
g.FillPolygon(brush, pts_tmp);
}
g也进行了定义:
```c#
Graphics g;//这个语句是全局定义的
g = this.CreateGraphics();//这个语句是在field_Load执行的
点击按钮后再点击网格中任意一处生成了蓝色的块,效果如下:
但如果按下alt键后蓝块就消失了,效果如下:
绘制的网格不变,是因为鼠标的点击造成了什么吗?
谢谢