Winform去掉标题栏后移动窗体
第一步:声明全局变量-> private Point _HoverTreePosition;
第二步:
#region 隐藏标题栏后移动窗口
private void Form_HoverTree_MouseDown(object sender, MouseEventArgs e)
{
_HoverTreePosition.X = e.X;
_HoverTreePosition.Y = e.Y;
}
private void Form_HoverTree_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Point h_myPosittion = MousePosition;
h_myPosittion.Offset(-_HoverTreePosition.X, -_HoverTreePosition.Y);
Location = h_myPosittion;
}
}
#endregion
第三步:在窗体上绑定MouseDown、MouseMove两个方法