// Process all the Logical and Raw Element Properties internal override object GetElementProperty(AutomationProperty idProp) { if (idProp == AutomationElement.IsOffscreenProperty) { Rect parentRect = GetParent().GetParent().BoundingRectangle; Rect itemRect = BoundingRectangle; if (itemRect.IsEmpty || parentRect.IsEmpty) { return(true); } // Need to check if this item is visible on the whole control not just its immediate parent. if (!Misc.IsItemVisible(ref parentRect, ref itemRect)) { return(true); } } else if (idProp == AutomationElement.HasKeyboardFocusProperty) { IAccessible acc = AccessibleObject; // The items are zero based, i.e. the first listview item is item 0. The // zero item in MSAA is self, so need to add one to the item to get the // correct Accessible child. AccessibleRole role = Accessible.GetRole(acc, _itemParent + 1); // ListView Iaccessible knows when its really a menu item if (role == AccessibleRole.MenuItem) { // Use the IsFocused of the Subitem instead the the one in ProxySimple // When ListViews are used for menus they don't get focus // so the check for "does this hwnd have focus" fails return(IsFocused()); } // If we are in a SysListView32 and that list view is in the Start Menu search column // real focus can stay on the edit box, while a virtual focus navigates the list // If this is the case, only check IsFocused, don't do the GetGUIThreadInfo check. IntPtr ancestor = _hwnd; IntPtr desktop = UnsafeNativeMethods.GetDesktopWindow(); while (ancestor != IntPtr.Zero && ancestor != desktop) { if (Misc.GetClassName(ancestor) == "Desktop Search Open View") { return(IsFocused()); } ancestor = Misc.GetParent(ancestor); } } return(base.GetElementProperty(idProp)); }
// ------------------------------------------------------ // // Constructors // //------------------------------------------------------ #region Constructors internal ListViewItemStartMenu(IntPtr hwnd, ProxyFragment parent, int item, IAccessible acc) : base(hwnd, parent, item) { // The items are zero based, i.e. the first listview item is item 0. The // zero item in MSAA is self, so need to add one to the item to get the // correct Accessible child. AccessibleRole role = Accessible.GetRole(acc, item + 1); // Normal Listview items should be of control type listitem. But // the Listview items in the Start Menu act like menuitems. Get the Role // from IAccessible interface implemented by the Shell team and set the // control type. if (role == AccessibleRole.MenuItem) { _cControlType = ControlType.MenuItem; } else { System.Diagnostics.Debug.Assert(false, "The listview item on the Start Menu has an unexpected IAccessible role!"); } }