namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
bool MouseIsDown; Point DownPosistion;
public Form1()
{
InitializeComponent();
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
MouseIsDown = false;
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
MouseIsDown = true;
DownPosistion = e.Location;
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (MouseIsDown)
{
Point x = new Point();
x.X = (Cursor.Position.X - DownPosistion.X);
x.Y = (Cursor.Position.Y - DownPosistion.Y);
Location = x;
}
}
}
}