#region 实现窗口移动 private bool m_isMouseDown = false; private Point m_mousePos = new Point(); protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); m_mousePos = Cursor.Position; m_isMouseDown = true; } protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); m_isMouseDown = false; } protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (m_isMouseDown) { Point tempPos = Cursor.Position; this.Location = new Point(Location.X + (tempPos.X - m_mousePos.X), Location.Y + (tempPos.Y - m_mousePos.Y)); m_mousePos = Cursor.Position; } } #endregion