im trying to draw crosshairs that follow the mouse around the screen. The following code works. but not quite, it draws a new crosshair for every mouse move, but doesnt remove the old one, so i end up with a screen full of vertical and horizontal lines.
how do i remove the last lines drawn on every mouse move?
how do i remove the last lines drawn on every mouse move?
Code:
public void MyMouseMove( Object sender, MouseEventArgs e )
{
Pen blackPen = new Pen(Color.FromArgb(128,0,0,255), 1);
Graphics g = SelectionRectangle.ActiveForm.CreateGraphics();
// Create coordinates of points that define line.
float formLeft = this.Left;
float formTop = this.Top ;
float formRight = this.Right ;
float formBottom = this.Bottom ;
mouseX = e.X ;
mouseY = e.Y ;
// Draw line to screen.
g.DrawLine(blackPen,0,mouseY,mouseX,mouseY );
g.DrawLine(blackPen, mouseX, 0, mouseX,mouseY);
g.DrawLine(blackPen, formRight, mouseY, mouseX, mouseY);
g.DrawLine(blackPen, mouseX, formBottom,mouseX, mouseY);