Beispiel #1
0
        /// <summary>
        ///     Moves a window to a screen.
        /// </summary>
        /// <param name="hWnd"> The window to move. </param>
        /// <param name="screenIndex"> The screen index or -1 to move to the primary screen. </param>
        /// <remarks>
        ///     <para>
        ///         Nothing happens if <paramref name="hWnd" /> is <see cref="IntPtr.Zero" />.
        ///     </para>
        /// </remarks>
        public static void MoveWindowToScreen(IntPtr hWnd, int screenIndex)
        {
            if (screenIndex < -1)
            {
                screenIndex = 0;
            }

            if (screenIndex >= Screen.AllScreens.Length)
            {
                screenIndex = Screen.AllScreens.Length - 1;
            }

            WindowsWindow.MoveWindowToScreen(hWnd, screenIndex == -1 ? null : Screen.AllScreens[screenIndex]);
        }
Beispiel #2
0
 /// <summary>
 ///     Moves a window to the primary screen.
 /// </summary>
 /// <param name="hWnd"> The window to move. </param>
 /// <remarks>
 ///     <para>
 ///         Nothing happens if <paramref name="hWnd" /> is <see cref="IntPtr.Zero" />.
 ///     </para>
 /// </remarks>
 public static void MoveWindowToPrimaryScreen(IntPtr hWnd)
 {
     WindowsWindow.MoveWindowToScreen(hWnd, null);
 }