Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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());
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }