Answers for "C# move form without border"

C#
1

c# make form draggable

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;
    }
Posted by: Guest on August-21-2020
0

C# move form without border

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);
}
Posted by: Guest on March-23-2020

C# Answers by Framework

Browse Popular Code Answers by Language