码迷,mamicode.com
首页 > 移动开发 > 详细

C# 鼠标点击移动窗体代码,可以实现无边框窗体的拖动

时间:2017-09-01 09:53:26      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:drag   无边框窗体的拖动   top   for   static   int   private   als   void   

private static bool IsDrag = false;
private int enterX;
private int enterY;
private void setForm_MouseDown(object sender, MouseEventArgs e)
{
IsDrag = true;
enterX = e.Location.X;
enterY = e.Location.Y;
}

private void setForm_MouseUp(object sender, MouseEventArgs e)
{
IsDrag = false;
enterX = 0;
enterY = 0;
}

private void setForm_MouseMove(object sender, MouseEventArgs e)
{
if (IsDrag)
{
Left += e.Location.X - enterX;
Top += e.Location.Y - enterY;
}
}

C# 鼠标点击移动窗体代码,可以实现无边框窗体的拖动

标签:drag   无边框窗体的拖动   top   for   static   int   private   als   void   

原文地址:http://www.cnblogs.com/dengfzj/p/7461336.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!