namespace Yw.WinFrmUI
{
///
/// FORM窗体拓展类
///
public static class FormExtensions
{
///
///
///
///
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
///
///
///
///
///
///
///
///
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
private const int VM_NCLBUTTONDOWN = 0X00A1;//定义鼠标左键按下
private const int HTCAPTION = 2;
///
/// 拖动移动
///
public static void DragMove(this Form frm)
{
//为当前应用程序释放鼠标捕获
ReleaseCapture();
//发送消息 让系统误以为在标题栏上按下鼠标
SendMessage(frm.Handle, VM_NCLBUTTONDOWN, HTCAPTION, 0);
}
}
}