Line disappears when I stop moving mouse

sem00009

Member
Joined
Nov 11, 2003
Messages
6
I got a very primitive problem, but its annoying to me. I am sure everybody here can easily help me - so I post it here and hope for a quick answer.

I am trying around with GDI+ and want to draw a simple line between 2 points in a control which simply disappears when I stop pressing the mouse button.

Outlined code, Method registerd as MouseEventHandlers, PaintEventHandlers to Objects... no override!

private void Paint(object sender, PaintEventArgs e){
if(dragMode){
Pen pen = new Pen(Color.White);
curGraphics.DrawLine(x1,y1,x2,y2);
}
}

private void MouseDown(object sender, MouseEventArgs e){
this.x1=e.X;
this.y1=e.Y;
this.dragMode = true;
// also tried this.Refresh here!
}

private void MouseMove(object sender, MouseEventArgs e){
this.x2=e.X;
this.y2=e.Y;
this.Refresh();
}

private void MouseUp(object sender, MouseEventArgs e){
this.dragMode=false;
// also tried this.Refresh here!
}

This works well, but when I stop moving the mouse the line disappears!!! Is there any "StopMovingMouseEvent" or what is my flaw here?

Thanks, Franz
 
Back
Top