Winfrom窗体在去掉窗体边框的情况下使鼠标移动窗体

来源:互联网 发布:卡门酒庄 知乎 编辑:程序博客网 时间:2024/05/22 14:22

1添加鼠标移动上去事件


扑捉新的坐标

  Point   downPoint;(提供有序的 x 坐标和 y 坐标整数对,该坐标对在二维平面中定义一个点。)



  private void FrmLogin_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                this.Location = new Point(this.Location.X + e.X - downPoint.X,
                    this.Location.Y + e.Y - downPoint.Y);
            }
        }



2添加按下鼠标事件


    private void FrmLogin_MouseDown(object sender, MouseEventArgs e)
        {
            downPoint = new Point(e.X, e.Y);
        }


0 0
原创粉丝点击