/// <summary>
        /// Set the window state of the named process
        /// </summary>
        /// <param name="processName"></param>
        /// <param name="state"></param>
        public static IntPtr SetWindowState(string processName, WINDOW_STATE state)
        {
            var process = Process.GetProcessesByName(processName).FirstOrDefault();

            if (process != null)
            {
                SetWindowState(process.MainWindowHandle, state);
                return(process.MainWindowHandle);
            }
            return(IntPtr.Zero);
        }
 private void switch_window_state()
 {
     if (window_state == WINDOW_STATE.BORDERLESS)
     {
         this.FormBorderStyle = FormBorderStyle.SizableToolWindow;
         window_state         = WINDOW_STATE.SIZEABLE;
     }
     else if (window_state == WINDOW_STATE.SIZEABLE)
     {
         this.FormBorderStyle = FormBorderStyle.None;
         window_state         = WINDOW_STATE.BORDERLESS;
     }
 }
Exemple #3
0
        /// <summary>
        /// Set process main window top state
        /// </summary>
        /// <param name="p"> Process </param>
        /// <param name="state"> Window state </param>
        public static void SetWindowState(Process p, WINDOW_STATE state)
        {
            bool res;

            if (state == WINDOW_STATE.TOP)
            {
                res = SetWindowPos(p.MainWindowHandle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
            }
            else
            {
                res = SetWindowPos(p.MainWindowHandle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
            }

            if (res == false)
            {
                throw new ProcessNotExistsException();
            }
        }
Exemple #4
0
 public static void SetWindowState(Process p, WINDOW_STATE state)
 {
     try
     {
         if (state == WINDOW_STATE.TOP)
         {
             SetWindowPos(GetWindowHandle(p), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
         }
         else
         {
             SetWindowPos(GetWindowHandle(p), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
         }
     }
     catch (ArgumentException)
     {
         throw new ProcessNotExistsException("Process doesnt exists");
     }
 }
Exemple #5
0
 public TopStateAction(Process p, WINDOW_STATE state)
 {
     this.proc     = p;
     this.state    = state;
     this.Reverted = false;
 }
Exemple #6
0
 private WINDOW_STATE Invert(WINDOW_STATE state)
 {
     return(state == WINDOW_STATE.TOP ? WINDOW_STATE.UNTOP : WINDOW_STATE.TOP);
 }
Exemple #7
0
 private TopStateAction(Process p, WINDOW_STATE state, bool reverted)
 {
     this.proc     = p;
     this.state    = state;
     this.Reverted = reverted;
 }
 private static extern bool ShowWindow(IntPtr hWnd, WINDOW_STATE state);
 /// <summary>
 /// Set the window state of the named process
 /// </summary>
 /// <param name="processName"></param>
 /// <param name="state"></param>
 public static IntPtr SetWindowState(string processName, WINDOW_STATE state)
 {
     var process = Process.GetProcessesByName(processName).FirstOrDefault();
     if (process != null)
     {
         SetWindowState(process.MainWindowHandle, state);
         return process.MainWindowHandle;
     }
     return IntPtr.Zero;
 }
 /// <summary>
 /// Set the window state by the window handle
 /// </summary>
 /// <param name="mainWindowHandle"></param>
 /// <param name="state"></param>
 private static void SetWindowState(IntPtr mainWindowHandle, WINDOW_STATE state)
 {
     ShowWindow(mainWindowHandle, state);
 }
 private static extern bool ShowWindow(IntPtr hWnd, WINDOW_STATE state);
 /// <summary>
 /// Set the window state by the window handle
 /// </summary>
 /// <param name="mainWindowHandle"></param>
 /// <param name="state"></param>
 private static void SetWindowState(IntPtr mainWindowHandle, WINDOW_STATE state)
 {
     ShowWindow(mainWindowHandle, state);
 }