How To Move a Border-less Dialog
Hi all,
As the title sugest, it is -standard- not possible to move a boderless dialog
(Keep mouse button depressed and move the cursor)
You have to make it.
So I came up with:
Code:
private void Dialog1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
while (Mouse.LeftButton == MouseButtonState.Pressed)
{
this.Location = new Point(MousePosition.X, MousePosition.Y);
this.Update();
}
}
but it does not work, however if I change pressed to depressed it works partly.
regards,
Ger
Re: How To Move a Border-less Dialog
Hi All,
Came up with the following:
Code:
// Move Dialog
private void Dialog1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
Down = true;
}
private void Dialog1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (Down == true)
{
if (Init == true)
{
Init = false;
Dialog = this.Location;
Mouse = new Point(MousePosition.X, MousePosition.Y);
Temp = new Point(Mouse.X - Dialog.X, Mouse.Y - Dialog.Y);
}
else
{
this.Location = new Point(MousePosition.X - Temp.X, MousePosition.Y - Temp.Y);
this.Update();
}
}
}
private void Dialog1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
Down = false;
Init = true;
}
//Declarations
Boolean Down = false;
Boolean Init = true;
Point Dialog;
Point Mouse;
Point Temp;
regards,
ger