我使用绘画事件在图片框中绘制了矩形。当我单击清除按钮时。我希望图形消失。每次鼠标移动时我都会调用绘画事件。我应该怎么办?
油漆事件中的代码:
Graphics^ g = e->Graphics;
float PenWidth = 2;
if(msdwnflag!=-1 && count%2==1)
{
if(selecflag==0)
{
g->DrawRectangle( gcnew Pen( Color::Blue,PenWidth ), RcDraw);
}
else
{
RcDraw.Width = finalMousePos.X- RcDraw.X;
RcDraw.Height = finalMousePos.Y- RcDraw.Y;
g->DrawRectangle( gcnew Pen( Color::Red,PenWidth ), RcDraw);
}
}