发布网友 发布时间:2022-04-21 18:23
共1个回答
热心网友 时间:2023-05-28 06:01
无边框窗体的移动: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; } }