ShowWindow() публичный статический Метод

public static ShowWindow ( IntPtr hWnd, bool show ) : bool
hWnd System.IntPtr
show bool
Результат bool
Пример #1
0
        IntPtr GetMsiForegroundWindow()
        {
            var proc = Process.GetProcessesByName("msiexec").Where(p => p.MainWindowHandle != IntPtr.Zero).FirstOrDefault();

            if (proc != null)
            {
                Win32.ShowWindow(proc.MainWindowHandle, Win32.SW_RESTORE);
                Win32.SetForegroundWindow(proc.MainWindowHandle);
                return(proc.MainWindowHandle);
            }
            else
            {
                return(IntPtr.Zero);
            }
        }
Пример #2
0
        /// <summary>
        /// Gets the msi foreground window.
        /// </summary>
        /// <returns></returns>
        protected virtual IntPtr GetMsiForegroundWindow()
        {
            Process proc = null;

            var bundleUI = Environment.GetEnvironmentVariable("WIXSHARP_SILENT_BA_PROC_ID");

            if (bundleUI != null)
            {
                int id = 0;
                if (int.TryParse(bundleUI, out id))
                {
                    proc = Process.GetProcessById(id);
                }
            }

            var bundlePath = session["WIXBUNDLEORIGINALSOURCE"];

            if (bundlePath.IsNotEmpty())
            {
                try
                {
                    proc = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(bundlePath)).Where(p => p.MainWindowHandle != IntPtr.Zero).FirstOrDefault();
                }
                catch { }
            }

            if (proc == null)
            {
                proc = Process.GetProcessesByName("msiexec").Where(p => p.MainWindowHandle != IntPtr.Zero).FirstOrDefault();
            }

            if (proc != null)
            {
                //IntPtr handle = proc.MainWindowHandle; //old algorithm

                IntPtr handle = MsiWindowFinder.GetMsiDialog(proc.Id);

                Win32.ShowWindow(handle, Win32.SW_RESTORE);
                Win32.SetForegroundWindow(handle);

                return(handle);
            }
            else
            {
                return(IntPtr.Zero);
            }
        }