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

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

Checks if any part of the specified window is obscured by a window belonging to a process other than ours
public static IsObscuredByNonACATWindows ( IntPtr windowHandle ) : bool
windowHandle System.IntPtr Window to check for
Результат bool
        public static bool IsObscuredByNonACATWindows(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);

                // is this a form created by our app?
                Control control = Form.FromHandle(hWnd);
                if (control != null)
                {
                    continue;
                }

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