/// <summary>
/// Moves the specified window to the monitor other than the one it is
/// currently in
/// </summary>
/// <param name="handle">Handle to the window</param>
public static void MoveWindowToOtherMonitor(IntPtr handle)
{
if (handle == IntPtr.Zero || !MultipleMonitors || Windows.IsMinimized(handle))
{
return;
}
var scr = GetMonitorForHandle(handle);
var other = scr.Primary ? GetSecondaryMonitor() : GetPrimaryMonitor();
if (Windows.IsMaximized(handle))
{
Windows.RestoreWindow(handle);
}
User32Interop.RECT rect;
User32Interop.GetWindowRect(handle, out rect);
User32Interop.MoveWindow(handle, other.WorkingArea.Left, other.WorkingArea.Top, rect.right - rect.left, rect.bottom - rect.top, true);
}