winform无边框窗口拖动

无边框的窗口想拖动,只需要在置顶的容器上添加对应的mousedown 和 mousemove 事件就可以实现了。代码如下:

 1         //拖动窗口
 2         private Point mPoint = new Point();
 3 
 4         private void panel1_MouseDown(object sender, MouseEventArgs e)
 5         {
 6             mPoint.X = e.X;
 7             mPoint.Y = e.Y;
 8         }
 9 
10         private void panel1_MouseMove(object sender, MouseEventArgs e)
11         {
12             if (e.Button == MouseButtons.Left)
13             {
14                 Point myPosittion = MousePosition;
15                 myPosittion.Offset(-mPoint.X, -mPoint.Y);
16                 Location = myPosittion;
17             }
18         }          

 

winform无边框窗口拖动

上一篇:win7下IIS的安装和配置 图文教程


下一篇:c# 操作PPT