首页 > 代码库 > C# 无边框窗体移动代码

C# 无边框窗体移动代码

C# 无边框窗体移动代码

        Point _frmPoint = new Point(); //移动前窗体左上角坐标        Point _mousePoint = new Point(); //按下鼠标时坐标        bool move = false; //是否移动        private void Form1_MouseDown(object sender, MouseEventArgs e)        {            _frmPoint = this.Location;            _mousePoint.X = e.X;            _mousePoint.Y = e.Y;            move = true;        }        private void Form1_MouseMove(object sender, MouseEventArgs e)        {            if (!move)                return;            _frmPoint.X += -_mousePoint.X + e.X;            _frmPoint.Y += -_mousePoint.Y+ e.Y;            this.Location = _frmPoint;        }        private void Form1_MouseUp(object sender, MouseEventArgs e)        {            move = false;        }

  

C# 无边框窗体移动代码