ACAT.Lib.Core.Utility.Windows.IsObscuredWindow C# (CSharp) Метод

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

Checks if any part of the specified window is obscured by another window. The other window could be one of this application's windows
public static IsObscuredWindow ( IntPtr windowHandle ) : bool
windowHandle System.IntPtr Window to check for
Результат bool
        public static bool IsObscuredWindow(IntPtr windowHandle)
        {
            if (windowHandle == null ||
                windowHandle == IntPtr.Zero ||
                !User32Interop.IsWindowVisible(windowHandle))
            {
                return false;
            }

            IntPtr hWnd = windowHandle;

            // store windows we have already visited
            var windowCache = new HashSet<IntPtr> { hWnd };

            User32Interop.RECT windowRect;
            User32Interop.GetWindowRect(hWnd, out windowRect);

            // check if any of the windows intersects with our window
            while ((hWnd = User32Interop.GetWindow(hWnd, User32Interop.GW_HWNDPREV)) != IntPtr.Zero &&
                        !windowCache.Contains(hWnd))
            {
                User32Interop.RECT rect;
                User32Interop.RECT intersection;

                windowCache.Add(hWnd);

                if (User32Interop.IsWindowVisible(hWnd) &&
                    !IsMinimized(hWnd) &&
                    User32Interop.GetWindowRect(hWnd, out rect) &&
                    User32Interop.IntersectRect(out intersection, ref windowRect, ref rect))
                {
                    return true;
                }
            }
            return false;
        }