简洁的 c# 拖动无标题栏窗体
2010-06-24 18:02
246 查看
using System.Runtime.InteropServices;
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MOVE = 0xF010;
public const int HTCAPTION = 0x0002;
MouseDown事件中加入如下代码:
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
}
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MOVE = 0xF010;
public const int HTCAPTION = 0x0002;
MouseDown事件中加入如下代码:
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
}
相关文章推荐
- C#无标题栏窗体鼠标拖动
- 拖动无标题的窗体(vb.net & c#)
- c#拖动无标题窗体
- C#无标题栏窗体鼠标拖动
- c# 实现用鼠标拖动没有标题栏的窗口(窗体的任何部分都可实现拖动效果)
- C#实现无标题栏窗体的拖动
- C#无标题栏窗体鼠标拖动
- C#无标题栏窗体鼠标拖动
- C# 使用重载消息处理函数的方式,实现没有标题栏的窗体的拖动。
- C#无标题栏窗体鼠标拖动
- C#实现无标题栏窗体的拖动
- C#无标题窗体的拖动
- C#拖动无标题栏窗体
- C#中怎么实现窗体无标题栏拖动
- C#无标题栏窗体鼠标拖动
- C#无标题栏窗体鼠标拖动
- c# 当窗体设置成无边框后,如何实现拖动效果,简洁实用
- C#无标题栏窗体鼠标拖动
- C#无标题栏窗体鼠标拖动
- c# 拖动无标题栏窗体代碼(轉)