I am currently using the code mentioned to move my form when clicking and moving the mouse on a specific control(in this case toolStrip).
private void toolStrip1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left) //Wenn die linke Maustaste gedrückt wurde,
FormMouseDownLocation = e.Location; //wird die Position der Maus gespeichert
}
private void toolStrip1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left) //Wird die Linke taste gedrückt und bewegt,
{
this.Left += e.X - FormMouseDownLocation.X; //so verschiebt sich das Fenster bei jeder Bewegung um die Positionänderung der Maus (hier die X Pos)
this.Top += e.Y - FormMouseDownLocation.Y; //so verschiebt sich das Fenster bei jeder Bewegung um die Positionänderung der Maus (hier die Y Pos)
}
}
Now I have a problem. The cursor is moving faster than the form, so often the cursor leaves the toolStrip and the form stops moving. This only happens, when I use this code combined with a control other than the mainform.
Is there any solution to this behaviour or maybe a better way to change the position of a form when clicking on another control?
Thanks in advance
Additional info: I am using winforms, FormBorderStyle: None