/// <summary> /// 设置一个值,该值指示控件是否已捕获鼠标。 /// </summary> /// <param name="hWnd">控件句柄。</param> /// <param name="value">如果控件已捕获鼠标,则为 true;否则为 false。</param> public static void SetCapture(IntPtr hWnd, bool value) { if (value) { UnsafeNativeMethods.SetCapture(hWnd); } else { UnsafeNativeMethods.ReleaseCapture(); } }
/// <summary> /// 开始拖动窗口 /// </summary> /// <param name="hWnd">窗口句柄</param> public static void BeginDrag(IntPtr hWnd) { UnsafeNativeMethods.ReleaseCapture(); UnsafeNativeMethods.SendMessage(hWnd, NativeMethods.WM_SYSCOMMAND, NativeMethods.SC_MOVE | NativeMethods.HTCAPTION, 0); }