你好每一个
我米新CreateGraphics主题。我有一个简单的图形应用程序,在那里我画了一个在窗口点击鼠标线在2个不同的点。线绘制在窗口。但我的问题是,当我切换到其他窗口列印回来我的项目窗口被清除。我以前的画线,将不存在
因此,如果有任何建议,请让我知道。我的代码是这样
public Form1()
{
InitializeComponent();
}
Point[] pts;
int pointcount = 0;
private void Form1_MouseClick(object sender, MouseEventArgs e)
{
if (pointcount == 0)
pts = new Point[2];
if (e.Button == MouseButtons.Left)
{
if (pointcount != 2)
{
pts[pointcount].X = e.X;
pts[pointcount].Y = e.Y;
++pointcount;
}
else
pointcount = 0;
if (pointcount == 2)
{
ghx.DrawCurve(Pens.Black, pts);
pointcount = 0;
}
}
}
Graphics ghx;
private void Form1_Load(object sender, EventArgs e)
{
ghx = CreateGraphics();
}