// To test if a list view item is offscreen, we need to
        // take into account the fact that it may be obscured by
        // the list view header.
        internal override bool IsOffscreen()
        {
            IntPtr hwndHeader = WindowsListView.ListViewGetHeader(_hwnd);

            if (hwndHeader != IntPtr.Zero)
            {
                NativeMethods.Win32Rect listViewRect = new NativeMethods.Win32Rect();
                NativeMethods.Win32Rect headerRect   = new NativeMethods.Win32Rect();
                if (Misc.GetWindowRect(hwndHeader, ref headerRect) &&
                    Misc.GetClientRectInScreenCoordinates(_hwnd, ref listViewRect))
                {
                    // Remove the listview header rect.
                    listViewRect.top = headerRect.bottom;

                    NativeMethods.Win32Rect itemRect =
                        new NativeMethods.Win32Rect(BoundingRectangle);
                    if (!listViewRect.IsEmpty &&
                        !Misc.IsItemVisible(ref listViewRect, ref itemRect))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        IRawElementProviderSimple [] ITableItemProvider.GetColumnHeaderItems()
        {
            IntPtr hwndHeader = WindowsListView.ListViewGetHeader(_hwnd);

            if (SafeNativeMethods.IsWindowVisible(hwndHeader))
            {
                WindowsSysHeader header = (WindowsSysHeader)WindowsSysHeader.Create(hwndHeader, 0);
                return(new IRawElementProviderSimple [] { new WindowsSysHeader.HeaderItem(hwndHeader, header, _item) });
            }
            return(null);
        }
        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        #region Internal Methods

        internal static int GetSubItemCount(IntPtr hwnd)
        {
            // Subitems are only available in details mode.
            if (WindowsListView.IsDetailMode(hwnd))
            {
                IntPtr hwndHeader = WindowsListView.ListViewGetHeader(hwnd);

                if (hwndHeader == IntPtr.Zero)
                {
                    return(0);
                }

                return(WindowsListView.HeaderItemCount(hwndHeader));
            }

            return(-1);
        }