Beispiel #1
0
 /// <summary>
 /// Resize the specified window.
 /// </summary>
 /// <param name="hWnd">The handle to the window.</param>
 /// <param name="x">The width of the new size.</param>
 /// <param name="y">The height of the new size.</param>
 public static void Resize(IntPtr hWnd, int width, int height)
 {
     WinAPI.SetWindowPos(hWnd, 0, 0, 0, width, height, 0x002);
 }
Beispiel #2
0
 /// <summary>
 /// Put focus on a window.
 /// </summary>
 /// <param name="hWnd">The handle to the window.</param>
 public static void SetFocused(IntPtr hWnd)
 {
     WinAPI.SetForegroundWindow(hWnd);
 }
Beispiel #3
0
 /// <summary>
 /// Move the specified window by the top left corner.
 /// </summary>
 /// <param name="hWnd">The handle to the window.</param>
 /// <param name="x">The x coordinate of the new position.</param>
 /// <param name="y">The y coordinate of the new position.</param>
 public static void Move(IntPtr hWnd, int x, int y)
 {
     WinAPI.SetWindowPos(hWnd, 0, x, y, 0, 0, 0x0001);
 }
Beispiel #4
0
 /// <summary>
 /// Allow a user to click through a window.
 /// </summary>
 /// <param name="Handle">The handle to the window.</param>
 public static void EnableMouseTransparency(IntPtr hWnd)
 {
     WinAPI.SetWindowLong(hWnd, -20, Convert.ToInt32(WinAPI.GetWindowLong(hWnd, -20) | 0x00080000 | 0x00000020L));
 }
Beispiel #5
0
 /// <summary>
 /// Get the handle of the window that is currently in focus.
 /// </summary>
 /// <returns>The handle to the focused Window.</returns>
 public static IntPtr GetFocused()
 {
     return(WinAPI.GetForegroundWindow());
 }
Beispiel #6
0
        /// <summary>
        /// Flip the layout of a window.
        /// </summary>
        /// <param name="hWnd">The handle to the window.</param>
        public static void FlipLeft(IntPtr hWnd)
        {
            var currentStyle = WinAPI.GetWindowLong(hWnd, -20);

            WinAPI.SetWindowLong(hWnd, -20, (currentStyle | (int)0x00400000L));
        }
Beispiel #7
0
 /// <summary>
 /// Flip the layout of a window back to its original state.
 /// </summary>
 /// <param name="hWnd">The handle to the window.</param>
 public static void FlipRight(IntPtr hWnd)
 {
     WinAPI.SetWindowLong(hWnd, -20, 0);
 }
Beispiel #8
0
 /// <summary>
 /// Close a window, but prompts the option to save before closing.
 /// </summary>
 /// <param name="hWnd">The handle to the window.</param>
 public static void Close(IntPtr hWnd)
 {
     // fShutDown = true will kill the window instantly
     // fShutDown = false will show the message box before closing for Saving Changes
     WinAPI.EndTask(hWnd, true, true);
 }
Beispiel #9
0
        /// <summary>
        /// Disable a window's minimize button.
        /// </summary>
        /// <param name="hWnd">The handle to the window.</param>
        public static void DisableMinimizeButton(IntPtr hWnd)
        {
            var currentStyle = WinAPI.GetWindowLong(hWnd, -16);

            WinAPI.SetWindowLong(hWnd, -16, (currentStyle & ~0x20000));
        }
Beispiel #10
0
 /// <summary>
 /// Minimize the specified window.
 /// </summary>
 /// <param name="hWnd">The handle to the window.</param>
 public static void Minimize(IntPtr hWnd)
 {
     WinAPI.ShowWindow(hWnd, 6);
 }
Beispiel #11
0
 /// <summary>
 /// Restore the specified window to its original position if it is maximized or minimized.
 /// </summary>
 /// <param name="hWnd">The handle to the window.</param>
 public static void Normalize(IntPtr hWnd)
 {
     WinAPI.ShowWindow(hWnd, 1);
 }
Beispiel #12
0
 /// <summary>
 /// Maximize the specified window.
 /// </summary>
 /// <param name="hWnd">The handle to the window.</param>
 public static void Maximize(IntPtr hWnd)
 {
     WinAPI.ShowWindow(hWnd, 3);
 }
Beispiel #13
0
        /// <summary>
        /// Check if a particular window is open.
        /// </summary>
        /// <param name="windowTitle">The title of the window.</param>
        /// <returns>True if the window is open.</returns>
        public static bool DoesExist(string windowTitle)
        {
            IntPtr hWnd = WinAPI.FindWindow(null, windowTitle);

            return(hWnd != IntPtr.Zero);
        }
Beispiel #14
0
 /// <summary>
 /// Change the specified window's title.
 /// </summary>
 /// <param name="hWnd">The handle to the window.</param>
 /// <param name="title">The new title.</param>
 public static void SetTitle(IntPtr hWnd, string title)
 {
     WinAPI.SetWindowText(hWnd, title);
 }
Beispiel #15
0
 /// <summary>
 /// Show the specified hidden window. Hidden is not the same as minimized.
 /// For minimized windows use the normalize method instead.
 /// </summary>
 /// <param name="hWnd">The handle to the window.</param>
 public static void Show(IntPtr hWnd)
 {
     WinAPI.SetWindowPos(hWnd, 0, 0, 0, 0, 0, 0x0040);
 }
Beispiel #16
0
 /// <summary>
 /// Hide the specified window.
 /// </summary>
 /// <param name="hWnd">The handle to the window.</param>
 public static void Hide(IntPtr hWnd)
 {
     WinAPI.SetWindowPos(hWnd, 0, 0, 0, 0, 0, 0x0080);
 }