WinForm可拖动的窗体
View Code
1 //全局 2 3 private int sx = 0; 4 private int sy = 0; 5 6 7 8 //窗体事件 9 10 private void PlayerForm_MouseDown(object sender, MouseEventArgs e) 11 { 12 this.sx = e.X; 13 this.sy = e.Y; 14 } 15 16 private void PlayerForm_MouseMove(object sender, MouseEventArgs e) 17 { 18 int dx = e.X - sx; 19 int dy = e.Y - sy; 20 21 if (e.Button == MouseButtons.Left) 22 { 23 this.Left += dx; 24 this.Top += dy; 25 } 26 }

浙公网安备 33010602011771号