/// <summary> /// Go through the list of all element chidren and exclude them from the list of /// visible/clickable rectangles. /// The element children may be listed in any order. A check on all of them must /// be performed. There is no easy way out. /// </summary> /// <param name="fragment"></param> /// <param name="alIn"></param> /// <param name="alOut"></param> internal static void ExcludeChildren(ProxyFragment fragment, ArrayList alIn, ArrayList alOut) { // First go through all the children to exclude whatever is on top for (ProxySimple simple = fragment.GetFirstChild(); simple != null; simple = fragment.GetNextSibling(simple)) { // The exclusion for hwnd children is done by the GetPoint routine if (simple is ProxyHwnd) { continue; } // Copy the output bits alIn.Clear(); alIn.AddRange(alOut); NativeMethods.Win32Rect rc = new NativeMethods.Win32Rect(simple.BoundingRectangle); CPRect rcp = new CPRect(ref rc, false); ClickablePoint.SplitRect(alIn, ref rcp, alOut, true); // recurse on the children if (simple is ProxyFragment) { ExcludeChildren((ProxyFragment)simple, alIn, alOut); } } }
// ------------------------------------------------------ // // Private Methods // // ------------------------------------------------------ #region Private Methods private static bool ClickableInRect(IntPtr hwnd, ref NativeMethods.Win32Point pt, bool fRiAsInsideRect, ArrayList alIn, ArrayList alOut) { if (!SafeNativeMethods.IsWindowVisible(hwnd)) { return(fRiAsInsideRect); } // Get the window rect. If this window has a width and it is effectivly invisible NativeMethods.Win32Rect rc = new NativeMethods.Win32Rect(); if (!Misc.GetWindowRect(hwnd, ref rc)) { return(fRiAsInsideRect); } if ((rc.right - rc.left) <= 0 || (rc.bottom - rc.top) <= 0) { return(fRiAsInsideRect); } // Try for transparency... if (fRiAsInsideRect) { int x = (rc.right + rc.left) / 2; int y = (rc.top + rc.bottom) / 2; try { int lr = Misc.ProxySendMessageInt(hwnd, NativeMethods.WM_NCHITTEST, IntPtr.Zero, NativeMethods.Util.MAKELPARAM(x, y)); if (lr == NativeMethods.HTTRANSPARENT) { return(true); } } // PRESHARP: Warning - Catch statements should not have empty bodies #pragma warning disable 6502 catch (TimeoutException) { // Ignore this timeout error. Avalon HwndWrappers have a problem with this WM_NCHITTEST call sometimes. } #pragma warning restore 6502 } // Copy the output bits alIn.Clear(); alIn.AddRange(alOut); CPRect rcp = new CPRect(ref rc, false); ClickablePoint.SplitRect(alIn, ref rcp, alOut, fRiAsInsideRect); if (!GetClickablePoint(alOut, out pt.x, out pt.y)) { return(false); } return(true); }