// Returns a Proxy element corresponding to the specified screen coordinates.
        internal override ProxySimple ElementProviderFromPoint(int x, int y)
        {
            UnsafeNativeMethods.TCHITTESTINFO hti = new UnsafeNativeMethods.TCHITTESTINFO();

            hti.pt = new NativeMethods.Win32Point(x, y);

            if (!Misc.MapWindowPoints(IntPtr.Zero, _hwnd, ref hti.pt, 1))
            {
                return(null);
            }

            // updown control goes over the tabs hence the order of the check
            // We cannot let UIAutomation do the do the drilling for the updown as the spinner covers the tab
            IntPtr updownHwnd = this.GetUpDownHwnd();

            if (updownHwnd != IntPtr.Zero && Misc.PtInWindowRect(updownHwnd, x, y))
            {
                return(null);
            }

            int index;

            unsafe
            {
                index = XSendMessage.XSendGetIndex(_hwnd, NativeMethods.TCM_HITTEST, IntPtr.Zero, new IntPtr(&hti), Marshal.SizeOf(hti.GetType()));
            }

            if (index >= 0)
            {
                return(CreateTabItem(index));
            }

            return(null);
        }
        private unsafe int getRebarBandIDFromPoint(NativeMethods.Win32Point pt)
        {
            NativeMethods.RB_HITTESTINFO rbHitTestInfo = new NativeMethods.RB_HITTESTINFO();
            rbHitTestInfo.pt     = pt;
            rbHitTestInfo.uFlags = 0;
            rbHitTestInfo.iBand  = 0;

            return(XSendMessage.XSendGetIndex(_hwnd, NativeMethods.RB_HITTEST, IntPtr.Zero, new IntPtr(&rbHitTestInfo), Marshal.SizeOf(rbHitTestInfo.GetType())));
        }
예제 #3
0
        // Returns a Proxy element corresponding to the specified screen coordinates.
        internal override ProxySimple ElementProviderFromPoint(int x, int y)
        {
            NativeMethods.Win32Point             pt      = new NativeMethods.Win32Point(x, y);
            NativeMethods.LVHITTESTINFO_INTERNAL hitTest = WindowsListView.SubitemHitTest(_hwnd, pt);

            if ((hitTest.flags & NativeMethods.LVHT_EX_GROUP_HEADER) != 0)
            {
                return(this);
            }

            if ((hitTest.flags & NativeMethods.LVHT_ONITEM) != 0 && hitTest.iItem >= 0)
            {
                // create the item
                return(new ListViewItem(_hwnd, this, hitTest.iItem));
            }

            // If we did not land on an item we may be at a subset link these only exist
            // in v6 comctrl and vista or later.
            if (_isComctrlV6OnOsVerV6orHigher)
            {
                // Allocate a local LVHITTESTINFO struct.
                NativeMethods.LVHITTESTINFO_V6 hitTestNative = new NativeMethods.LVHITTESTINFO_V6(hitTest);
                unsafe
                {
                    XSendMessage.XSendGetIndex(_hwnd, NativeMethods.LVM_HITTEST, new IntPtr(-1), new IntPtr(&hitTestNative), Marshal.SizeOf(hitTestNative.GetType()));
                }

                if ((hitTestNative.flags & NativeMethods.LVHT_EX_GROUP_SUBSETLINK) != 0)
                {
                    GroupManager.GroupInfo groupInfo = GetGroupInfo(_hwnd, ID);
                    int [] items = groupInfo._items;
                    if (groupInfo._count <= 0 || groupInfo._count > items.Length)
                    {
                        return(null);
                    }

                    int index = items [groupInfo._count - 1];
                    return(CreateGroupSubsetLink(index + 1));
                }
            }

            return(this);
        }
        // Returns a Proxy element corresponding to the specified screen coordinates.
        internal override ProxySimple ElementProviderFromPoint(int x, int y)
        {
            NativeMethods.HDHITTESTINFO HitTestInfo = new NativeMethods.HDHITTESTINFO();

            HitTestInfo.pt = new NativeMethods.Win32Point(x, y);

            int index = -1;

            if (Misc.MapWindowPoints(IntPtr.Zero, _hwnd, ref HitTestInfo.pt, 1))
            {
                unsafe
                {
                    index = XSendMessage.XSendGetIndex(_hwnd, NativeMethods.HDM_HITTEST, IntPtr.Zero, new IntPtr(&HitTestInfo), Marshal.SizeOf(HitTestInfo.GetType()));
                }
            }

            // make sure that hit-test happened on the header item itself
            if (index != -1 && (NativeMethods.HHT_ONHEADER == (HitTestInfo.flags & 0x000F)))
            {
                return(CreateHeaderItem(GetItemFromIndex(index)));
            }

            return(this);
        }