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);
        }