public static bool IsOverlapped()

in 2LCS/Forms/MainForm.cs [141:165]


        public static bool IsOverlapped(IWin32Window window)
        {
            if (window == null)
                throw new ArgumentNullException(nameof(window));
            if (window.Handle == IntPtr.Zero)
                throw new InvalidOperationException("Window does not yet exist");
            if (!IsWindowVisible(window.Handle))
                return false;

            IntPtr hWnd = window.Handle;
            HashSet<IntPtr> visited = new HashSet<IntPtr> { hWnd };
            _ = new RECT();
            GetWindowRect(hWnd, out RECT thisRect);

            while ((hWnd = GetWindow(hWnd, GW_HWNDPREV)) != IntPtr.Zero && !visited.Contains(hWnd))
            {
                visited.Add(hWnd);
                _ = new RECT();
                if (IsWindowVisible(hWnd) && GetWindowRect(hWnd, out RECT testRect) && IntersectRect(out _, ref thisRect, ref testRect))
                {
                    return true;
                }
            }
            return false;
        }