首页 > 代码库 > FormBorderStyle为None的时候如何拖动窗体
FormBorderStyle为None的时候如何拖动窗体
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 #endregion19 #region 构造函数20 public Form1()21 {22 //初始化窗体信息23 //InitializeComponent();24 //绑定鼠标拖动窗体事件25 this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form_MouseDown);26 }27 #endregion28 }
参考:
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。