示例#1
0
        public static IntPtr BringWindowToFront(
            string name,
            bool _,
            bool isRetoreMinimizedWindow = false)
        {
            IntPtr window = InteropWindow.FindWindow((string)null, name);

            if (window == IntPtr.Zero)
            {
                throw new SystemException("Cannot find window '" + name + "'", (Exception) new Win32Exception(Marshal.GetLastWin32Error()));
            }
            if (!InteropWindow.SetForegroundWindow(window))
            {
                throw new SystemException("Cannot set foreground window", (Exception) new Win32Exception(Marshal.GetLastWin32Error()));
            }
            if (isRetoreMinimizedWindow)
            {
                InteropWindow.ShowWindow(window, 9);
            }
            else
            {
                InteropWindow.ShowWindow(window, 5);
            }
            return(window);
        }
示例#2
0
        public static IntPtr GetWindowHandle(string name)
        {
            IntPtr window = InteropWindow.FindWindow((string)null, name);

            if (!(window == IntPtr.Zero))
            {
                return(window);
            }
            throw new SystemException("Cannot find window '" + name + "'", (Exception) new Win32Exception(Marshal.GetLastWin32Error()));
        }
示例#3
0
        public static IntPtr MinimizeWindow(string name)
        {
            IntPtr window = InteropWindow.FindWindow((string)null, name);

            if (window == IntPtr.Zero)
            {
                throw new SystemException("Cannot find window '" + name + "'", (Exception) new Win32Exception(Marshal.GetLastWin32Error()));
            }
            InteropWindow.ShowWindow(window, 6);
            return(window);
        }