c#移动无边框窗体
2014-06-18 14:27
302 查看
//[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;
//private void Frm_AdvisementDetection_MouseDown(object sender, MouseEventArgs e)
//{
// ReleaseCapture();
// SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
//}
在窗体类中加入如下代码:
[csharp] view
plaincopyprint?
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事件中加入以下两句:
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
就搞定了。
//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;
//private void Frm_AdvisementDetection_MouseDown(object sender, MouseEventArgs e)
//{
// ReleaseCapture();
// SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
//}
在窗体类中加入如下代码:
[csharp] view
plaincopyprint?
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事件中加入以下两句:
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
就搞定了。
相关文章推荐
- c#无边框窗体移动 屏蔽双击最大化
- C#中无边框窗体随意移动代码
- C#中无边框窗体移动
- C#开发——窗体去边框之后无法移动解决办法
- C# .net WPF无边框移动窗体
- c#窗体移动(无边框移动/用户区移动)
- C# 移动无边框窗体
- C#中无边框窗体移动的简单实例
- 使用C#实现移动无边框窗体
- C# 无边框窗体移动 点击任务栏实现最小化与还原
- C# 无边框窗体移动
- C# 窗体无边框 实现窗体移动(可在指定位置)
- C# 移动无边框的窗体
- C#中无边框窗体移动
- [转]C#无边框窗体移动的三种方法
- C# 无边框窗体的移动,任务栏右键菜单,调整大小
- c# winform移动无边框窗体
- C#无边框窗体的移动
- C# 无边框窗体之窗体移动
- C# winform中无边框窗体的移动