bool canMove = false;
Point p;
private void Form1_MouseLeave(object sender, EventArgs e)
{
canMove = false;
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
canMove = true;
p = e.Location;
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
canMove = false;
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (canMove)
{
pic = (PictureBox)sender;
pic.Top += e.Y - p.Y;
pic.Left += e.X - p.X;
}
}
|