无边框Winform窗体移动的几种方式
1个回答
展开全部
无边框窗体的移动:bool formMove = false;//窗体是否移动 Point formPoint;//记录窗体的位置 private void AddFriendForm2_MouseDown(object sender, MouseEventArgs e) { formPoint = new Point(); int xOffset; int yOffset; if (e.Button == MouseButtons.Left) { xOffset = -e.X - SystemInformation.FrameBorderSize.Width; yOffset = -e.Y - SystemInformation.CaptionHeight - SystemInformation.FrameBorderSize.Height; formPoint = new Point(xOffset, yOffset); formMove = true;//开始移动 } } private void AddFriendForm2_MouseMove(object sender, MouseEventArgs e) { if (formMove == true) { Point mousePos = Control.MousePosition; mousePos.Offset(formPoint.X, formPoint.Y); Location = mousePos; } }
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询