Exemplo n.º 1
0
 public void Flash()
 {
     if (this.CheckHandle())
     {
         WindowInformation.FlashWindow(this.Handle, true);
     }
 }
Exemplo n.º 2
0
        private static bool MyEnumDesktopWindows(IntPtr hwnd, IntPtr lParam)
        {
            IntPtr windowThreadProcessId = WindowInformation.GetWindowThreadProcessId(hwnd, 0);
            IntPtr threadDesktop         = WindowInformation.GetThreadDesktop(windowThreadProcessId);

            WindowInformation.CloseDesktop(threadDesktop);
            bool result;

            if (threadDesktop == lParam)
            {
                WindowInformation windowInformation = new WindowInformation(hwnd);
                if (!windowInformation.Visible)
                {
                    result = true;
                    return(result);
                }
                string text = windowInformation.Text;
                if (text == null || text.Length == 0)
                {
                    result = true;
                    return(result);
                }
                WindowInformation.myDesktopWindows.Add(windowInformation);
            }
            result = true;
            return(result);
        }
Exemplo n.º 3
0
        public bool SetParent(IntPtr newParentHandle)
        {
            bool result;

            if (newParentHandle == IntPtr.Zero || !WindowInformation.IsWindow(newParentHandle))
            {
                result = false;
            }
            else if (this.CheckHandle())
            {
                IntPtr value = WindowInformation.SetParent(this.Handle, newParentHandle);
                if (value == IntPtr.Zero)
                {
                    this.InnerThrowWin32Exception();
                    result = false;
                }
                else
                {
                    result = true;
                }
            }
            else
            {
                result = false;
            }
            return(result);
        }
Exemplo n.º 4
0
 public void Activate()
 {
     if (this.CheckHandle())
     {
         WindowInformation.SetForegroundWindow(this.Handle);
     }
 }
Exemplo n.º 5
0
 public void Close()
 {
     if (this.CheckHandle())
     {
         WindowInformation.SendMessage(this.Handle, 16, 0, 0);
     }
 }
Exemplo n.º 6
0
        public bool IsParent(IntPtr parentHandle)
        {
            bool result;

            if (parentHandle == IntPtr.Zero || !WindowInformation.IsWindow(parentHandle))
            {
                result = false;
            }
            else
            {
                if (this.CheckHandle())
                {
                    IntPtr intPtr = this.Handle;
                    while (intPtr != IntPtr.Zero)
                    {
                        intPtr = WindowInformation.GetParent(intPtr);
                        if (intPtr == parentHandle)
                        {
                            result = true;
                            return(result);
                        }
                        if (intPtr == IntPtr.Zero)
                        {
                            break;
                        }
                    }
                }
                result = false;
            }
            return(result);
        }
Exemplo n.º 7
0
 public void BringToTop()
 {
     if (this.CheckHandle())
     {
         if (!WindowInformation.BringWindowToTop(this.Handle))
         {
             this.InnerThrowWin32Exception();
         }
     }
 }
        public bool UpdateLayout()
        {
            WindowInformation windowInformation  = new WindowInformation(this.ControlHandle);
            WindowInformation windowInformation2 = new WindowInformation(this.ContainerHandle);
            bool result;

            if (!windowInformation.CheckHandle() || !windowInformation2.CheckHandle())
            {
                result = false;
            }
            else
            {
                if (windowInformation.ParentHandle != windowInformation2.Handle)
                {
                    if (!windowInformation.SetParent(windowInformation2.Handle))
                    {
                        result = false;
                        return(result);
                    }
                }
                Rectangle clientBounds = windowInformation2.ClientBounds;
                Rectangle bounds       = windowInformation.Bounds;
                Rectangle rectangle    = bounds;
                switch (this.Dock)
                {
                case DockStyle.Top:
                    rectangle = new Rectangle(0, 0, clientBounds.Width, bounds.Height);
                    break;

                case DockStyle.Bottom:
                    rectangle = new Rectangle(0, clientBounds.Height - bounds.Height, clientBounds.Width, bounds.Height);
                    break;

                case DockStyle.Left:
                    rectangle = new Rectangle(0, 0, bounds.Width, clientBounds.Height);
                    break;

                case DockStyle.Right:
                    rectangle = new Rectangle(clientBounds.Width - bounds.Width, 0, bounds.Width, clientBounds.Height);
                    break;

                case DockStyle.Fill:
                    rectangle = clientBounds;
                    break;
                }
                if (rectangle != bounds)
                {
                    windowInformation.Bounds = rectangle;
                }
                result = true;
            }
            return(result);
        }
Exemplo n.º 9
0
        public static WindowInformation FromHandle(IntPtr handle)
        {
            WindowInformation result;

            if (WindowInformation.CheckHandle(handle))
            {
                WindowInformation windowInformation = new WindowInformation(handle);
                result = windowInformation;
            }
            else
            {
                result = null;
            }
            return(result);
        }
Exemplo n.º 10
0
        public static WindowInformation GetFocusWindow()
        {
            IntPtr            focus = WindowInformation.GetFocus();
            WindowInformation result;

            if (focus != IntPtr.Zero)
            {
                result = new WindowInformation(focus);
            }
            else
            {
                result = null;
            }
            return(result);
        }
Exemplo n.º 11
0
        public Process GetOwnerProcess()
        {
            Process result;

            if (this.CheckHandle())
            {
                int num = 0;
                int windowThreadProcessId = WindowInformation.GetWindowThreadProcessId(this.Handle, ref num);
                if (num != 0)
                {
                    result = Process.GetProcessById(num);
                    return(result);
                }
            }
            result = null;
            return(result);
        }
Exemplo n.º 12
0
        public WindowInformation GetTopLevelParentWindow()
        {
            WindowInformation[] desktopWindows = WindowInformation.DesktopWindows;
            WindowInformation   result;

            for (WindowInformation windowInformation = this; windowInformation != null; windowInformation = windowInformation.Parent)
            {
                WindowInformation[] array = desktopWindows;
                for (int i = 0; i < array.Length; i++)
                {
                    WindowInformation windowInformation2 = array[i];
                    if (windowInformation2.Handle == windowInformation.Handle)
                    {
                        result = windowInformation2;
                        return(result);
                    }
                }
            }
            result = null;
            return(result);
        }
Exemplo n.º 13
0
 public static bool CheckHandle(IntPtr handle)
 {
     return(!(handle == IntPtr.Zero) && WindowInformation.IsWindow(handle));
 }
Exemplo n.º 14
0
 public bool CheckHandle()
 {
     return(!(this.myControl.Handle == IntPtr.Zero) && WindowInformation.IsWindow(this.myControl.Handle));
 }