/// <summary>
/// Maximizes the specified window in the monitor other than the
/// one it is currently in
/// </summary>
/// <param name="handle">Window handle</param>
public static void MaximizeWindowInOtherMonitor(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);
User32Interop.ShowWindow(handle.ToInt32(), Windows.ShowWindowFlags.SW_SHOWMAXIMIZED);
}