FormBorderStyle为None的时候如何拖动窗体

2020-12-13 04:46

阅读:508

标签:style   blog   http   color   os   io   

 

soscw.com,搜素材soscw.com,搜素材
 1 //为DllImport导出命名空间,
 2 using System.Runtime.InteropServices;
 3 public partial class Form1 : System.Windows.Forms.Form
 4 {
 5 #region FormBorderStyle为None,拖放窗体
 6 [DllImport("user32.dll")]
 7 public static extern bool ReleaseCapture();
 8 [DllImport("user32.dll")]
 9 public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
10 public const int WM_SYSCOMMAND = 0x0112;
11 public const int SC_MOVE = 0xF010;
12 public const int HTCAPTION = 0x0002;
13 private void Form_MouseDown(object sender, MouseEventArgs e)
14 {
15 ReleaseCapture();
16 SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
17 }
18 #endregion
19 #region 构造函数
20 public Form1()
21 {
22 //初始化窗体信息
23 //InitializeComponent();
24 //绑定鼠标拖动窗体事件
25 this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form_MouseDown);
26 }
27 #endregion
28 }
View Code

 

参考: 

http://www.dxper.net/thread-2525-1-1.html
http://www.cnblogs.com/rogation/p/3508266.html
DllImport:http://blog.csdn.net/jame_peng/article/details/4387906

FormBorderStyle为None的时候如何拖动窗体,搜素材,soscw.com

FormBorderStyle为None的时候如何拖动窗体

标签:style   blog   http   color   os   io   

原文地址:http://www.cnblogs.com/huangtailang/p/3848937.html


评论


亲,登录后才可以留言!