Bob Bello
8
Q:

C# move form without border

private bool mouseDown;
private Point lastLocation;

    private void Form1_MouseDown(object sender, MouseEventArgs e)
    {
        mouseDown = true;
        lastLocation = e.Location;
    }

    private void Form1_MouseMove(object sender, MouseEventArgs e)
    {
        if(mouseDown)
        {
            this.Location = new Point(
                (this.Location.X - lastLocation.X) + e.X, (this.Location.Y - lastLocation.Y) + e.Y);

            this.Update();
        }
    }

    private void Form1_MouseUp(object sender, MouseEventArgs e)
    {
        mouseDown = false;
    }
2
protected override void WndProc(ref Message m)
{
	switch(m.Msg)
	{
		case 0x84:
			base.WndProc(ref m);
			if((int)m.Result == 0x1)
				m.Result = (IntPtr)0x2;
			return;
	}

	base.WndProc(ref m);
}
0

New to Communities?

Join the community