// Gets the windows handle of an individual tab in a Windows Forms control private IntPtr GetItemHwndByIndex() { // On Win32 Tab controls the table page is parented by the dialog box not the // Tab control. IntPtr hwndParent = _hwnd; if (!_fIsWinform) { hwndParent = Misc.GetParent(hwndParent); } if (hwndParent != IntPtr.Zero) { // Get the tab name and match it with the window title of one of the children string sName = WindowsTabItem.GetName(_hwnd, _item, true); // If there is no tab name there is no way to match to one of the childrens window title. if (!string.IsNullOrEmpty(sName)) { return(Misc.FindWindowEx(hwndParent, IntPtr.Zero, null, sName)); } } return(IntPtr.Zero); }
// if all the tab items have no name then the control is not useful internal static bool IsValidControl(IntPtr hwnd) { for (int i = 0, c = GetItemCount(hwnd); i < c; i++) { if (!string.IsNullOrEmpty(WindowsTabItem.GetName(hwnd, i, true))) { return(true); } } return(false); }
// Process all the Logical and Raw Element Properties internal override object GetElementProperty(AutomationProperty idProp) { if (idProp == AutomationElement.AccessKeyProperty && _windowsForms != WindowsFormsHelper.FormControlState.True) { return(Misc.AccessKey(WindowsTabItem.GetItemText(_hwnd, _item))); } else if (idProp == AutomationElement.IsControlElementProperty) { return(!string.IsNullOrEmpty(GetName(_hwnd, _item, true))); } return(base.GetElementProperty(idProp)); }
private bool IsTabPage(IntPtr hwnd, out IntPtr hwndTab, out int item) { hwndTab = IntPtr.Zero; item = -1; if (!SafeNativeMethods.IsWindowVisible(hwnd)) { return(false); } try { if (!HasTabPageStyle(hwnd)) { return(false); } } catch (ElementNotAvailableException) { // if the received an ElementNotAvailableException this hwnd can not be a // tab page so return false. return(false); } string dlgName = Misc.ProxyGetText(hwnd); // if the dialog does not have a title there is no way to match to a tab item. if (string.IsNullOrEmpty(dlgName)) { return(false); } IntPtr hwndParent = Misc.GetParent(hwnd); if (hwndParent == IntPtr.Zero) { return(false); } hwndTab = Misc.FindWindowEx(hwndParent, IntPtr.Zero, "SysTabControl32", null); // if the tab control is invisible then the tab control is not there. if (hwndTab == IntPtr.Zero || !SafeNativeMethods.IsWindowVisible(hwndTab)) { return(false); } item = WindowsTabItem.GetCurrentSelectedItem(hwndTab); return(dlgName.Equals(WindowsTabItem.GetName(hwndTab, item, true))); }
// Returns an enumerator over the current selection. IRawElementProviderSimple[] ISelectionProvider.GetSelection() { IRawElementProviderSimple[] selection = null; // If only one selection allowed, get selected item, if any, and add to list if (!WindowsTab.SupportMultipleSelection(_hwnd)) { int selectedItem = WindowsTabItem.GetCurrentSelectedItem(_hwnd); if (selectedItem >= 0) { selection = new IRawElementProviderSimple[1]; selection[0] = CreateTabItem(selectedItem); } } // If multiple selections allowed, check each tab for selected state else { ArrayList list = new ArrayList(); for (ProxySimple child = GetFirstChild(); child != null; child = GetNextSibling(child)) { if (((ISelectionItemProvider)child).IsSelected) { list.Add(child); } } int count = list.Count; if (count <= 0) { return(null); } selection = new IRawElementProviderSimple[count]; for (int i = 0; i < count; i++) { selection[i] = (ProxySimple)list[i]; } } return(selection); }
//------------------------------------------------------ // // Interface IRawElementProviderHwndOverride // //------------------------------------------------------ IRawElementProviderSimple IRawElementProviderHwndOverride.GetOverrideProviderForHwnd(IntPtr hwnd) { // return the appropriate placeholder for the given hwnd... // loop over all the tabs to find it. string sTitle = Misc.ProxyGetText(hwnd); // If there is no hwnd title there is no way to match to the tab item. if (string.IsNullOrEmpty(sTitle)) { return(null); } for (int i = 0, c = GetItemCount(_hwnd); i < c; i++) { if (sTitle == WindowsTabItem.GetName(_hwnd, i, true)) { return(new WindowsTabChildOverrideProxy(hwnd, CreateTabItem(i), i)); } } return(null); }