示例#1
0
        /// <summary>
        /// Repositions an actively running application's window.
        /// </summary>
        /// <param name="processName">The process name of the application.</param>
        /// <param name="position">The Position instance to set the application's window to.</param>
        public static void MoveWindow(string processName, Position position)
        {
            Process[] processes = Process.GetProcesses();
            Process   prcs      = new Process();

            foreach (Process p in processes)
            {
                if (p.ProcessName == processName)
                {
                    prcs = p;
                    break;
                }
            }
            DLLInterops.SetWindowPos(prcs.MainWindowHandle, 0, position.X, position.Y, position.Width, position.Height, DLLInterops.SWP_NOZORDER);
        }