首页 > 代码库 > formborderstyle设为none之后怎么移动窗体?

formborderstyle设为none之后怎么移动窗体?

        bool formMove = false;//窗体是否移动
        Point formPoint=new Point();//记录窗体的位置
        int x;
        int y;
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                x = e.X;
                y = e.Y;
                formMove = true;//开始移动
            }
        }
        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            if (formMove == true)
            {
                formPoint.X = Control.MousePosition.X - x;
                formPoint.Y = Control.MousePosition.Y - y;
                Location = formPoint;
            }
        }
        private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)//按下的是鼠标左键
            {
                formMove = false;//停止移动
            }
        }

formborderstyle设为none之后怎么移动窗体?