Esempio n. 1
0
        // Static create method called by the event tracker system.
        // WinEvents are raised only when a notification has been set for a
        // specific item. Create the item first and check for details afterward.
        internal static void RaiseEvents(IntPtr hwnd, int eventId, object idProp, int idObject, int idChild)
        {
            WindowsScrollBar wtv = new WindowsScrollBar(hwnd, null, -1, NativeMethods.SB_CTL);

            if (idChild == 0 && eventId == NativeMethods.EventObjectStateChange && idProp == ValuePattern.IsReadOnlyProperty)
            {
                // UIA works differently than MSAA. Events are set for elements rather than hwnd
                // Scroll bar are processed the same way whatever they are part of the non client area
                // or stand alone hwnd. OBJID_HSCROLL and OBJID_VSCROLL are mapped to OBJID_WINDOW
                // so they behave the same for NC and hwnd SB.
                // Parameters are setup so that the dispatch will send the proper notification and
                // recursively will send notifications to all of the children
                if (idObject == NativeMethods.OBJID_HSCROLL || idObject == NativeMethods.OBJID_VSCROLL)
                {
                    idObject = NativeMethods.OBJID_WINDOW;
                }
            }

            if (idChild == 0)
            {
                wtv.DispatchEvents(eventId, idProp, idObject, idChild);
            }
            else
            {
                // raise events for the children
                ProxySimple scrollBarBit = WindowsScrollBarBits.CreateFromChildId(hwnd, wtv, idChild, NativeMethods.SB_CTL);
                if (scrollBarBit != null)
                {
                    scrollBarBit.DispatchEvents(eventId, idProp, idObject, idChild);
                }
            }
        }
Esempio n. 2
0
        // Returns a Proxy element corresponding to the specified screen coordinates.
        internal override ProxySimple ElementProviderFromPoint(int x, int y)
        {
            for (ScrollBarItem item = ScrollBarItem.UpArrow; (int)item <= (int)ScrollBarItem.DownArrow; item = (ScrollBarItem)((int)item + 1))
            {
                NativeMethods.Win32Rect rc = new NativeMethods.Win32Rect(WindowsScrollBarBits.GetBoundingRectangle(_hwnd, this, item, _sbFlag));

                if (Misc.PtInRect(ref rc, x, y))
                {
                    return(new WindowsScrollBarBits(_hwnd, this, (int)item, _sbFlag));
                }
            }

            return(this);
        }
Esempio n. 3
0
        private static void RaiseEventsOnScroll(IntPtr hwnd, int eventId, object idProp, int idObject, int idChild)
        {
            if ((idProp == ScrollPattern.VerticalScrollPercentProperty && idObject != NativeMethods.OBJID_VSCROLL) ||
                (idProp == ScrollPattern.HorizontalScrollPercentProperty && idObject != NativeMethods.OBJID_HSCROLL))
            {
                return;
            }

            ProxyFragment el = new NonClientArea(hwnd);

            if (el == null)
            {
                return;
            }

            if (idProp == InvokePattern.InvokedEvent)
            {
                NonClientItem item      = idObject == NativeMethods.OBJID_HSCROLL ? NonClientItem.HScrollBar : NonClientItem.VScrollBar;
                int           sbFlag    = idObject == NativeMethods.OBJID_HSCROLL ? NativeMethods.SB_HORZ : NativeMethods.SB_VERT;
                ProxyFragment scrollBar = new WindowsScrollBar(hwnd, el, (int)item, sbFlag);
                if (scrollBar != null)
                {
                    ProxySimple scrollBarBit = WindowsScrollBarBits.CreateFromChildId(hwnd, scrollBar, idChild, sbFlag);
                    if (scrollBarBit != null)
                    {
                        scrollBarBit.DispatchEvents(eventId, idProp, idObject, idChild);
                    }
                }

                return;
            }

            if (eventId == NativeMethods.EventObjectStateChange && idProp == ValuePattern.IsReadOnlyProperty)
            {
                if (idChild == 0)
                {
                    //



                    if (idObject == NativeMethods.OBJID_HSCROLL || idObject == NativeMethods.OBJID_VSCROLL)
                    {
                        idObject = NativeMethods.OBJID_WINDOW;
                    }
                    el.DispatchEvents(eventId, idProp, idObject, idChild);
                }
                return;
            }

            if (idProp == ValuePattern.ValueProperty && eventId == NativeMethods.EVENT_OBJECT_VALUECHANGE)
            {
                NonClientItem    item      = idObject == NativeMethods.OBJID_HSCROLL ? NonClientItem.HScrollBar : NonClientItem.VScrollBar;
                WindowsScrollBar scrollBar = new WindowsScrollBar(hwnd, el, (int)item, idObject == NativeMethods.OBJID_HSCROLL ? NativeMethods.SB_HORZ : NativeMethods.SB_VERT);
                scrollBar.DispatchEvents(0, ValuePattern.ValueProperty, NativeMethods.OBJID_CLIENT, 0);
                return;
            }

            if (Misc.GetClassName(hwnd) == "ComboLBox")
            {
                el = (ProxyFragment)WindowsListBox.Create(hwnd, 0);
            }

            if (el != null)
            {
                el.DispatchEvents(eventId, idProp, idObject, idChild);
            }
        }
        private static void RaiseEventsOnScroll(IntPtr hwnd, int eventId, object idProp, int idObject, int idChild)
        {
            if ((idProp == ScrollPattern.VerticalScrollPercentProperty && idObject != NativeMethods.OBJID_VSCROLL) ||
                (idProp == ScrollPattern.HorizontalScrollPercentProperty && idObject != NativeMethods.OBJID_HSCROLL))
            {
                return;
            }

            ProxyFragment el = new NonClientArea(hwnd);

            if (el == null)
            {
                return;
            }

            if (idProp == InvokePattern.InvokedEvent)
            {
                NonClientItem item      = idObject == NativeMethods.OBJID_HSCROLL ? NonClientItem.HScrollBar : NonClientItem.VScrollBar;
                int           sbFlag    = idObject == NativeMethods.OBJID_HSCROLL ? NativeMethods.SB_HORZ : NativeMethods.SB_VERT;
                ProxyFragment scrollBar = new WindowsScrollBar(hwnd, el, (int)item, sbFlag);
                if (scrollBar != null)
                {
                    ProxySimple scrollBarBit = WindowsScrollBarBits.CreateFromChildId(hwnd, scrollBar, idChild, sbFlag);
                    if (scrollBarBit != null)
                    {
                        scrollBarBit.DispatchEvents(eventId, idProp, idObject, idChild);
                    }
                }

                return;
            }

            if (eventId == NativeMethods.EventObjectStateChange && idProp == ValuePattern.IsReadOnlyProperty)
            {
                if (idChild == 0)
                {
                    // This code is never exercised. The code in User needs to change to send
                    // EventObjectStateChange with a client ID of zero
                    //
                    // UIA works differently than MSAA. Events are set for elements rather than hwnd
                    // Scroll bar are processed the same way whatever they are part of the non client area
                    // or stand alone hwnd. OBJID_HSCROLL and OBJID_VSCROLL are mapped to OBJID_WINDOW
                    // so they behave the same for NC and hwnd SB.
                    // Parameters are setup so that the dispatch will send the proper notification and
                    // recursively will send notifications to all of the children
                    if (idObject == NativeMethods.OBJID_HSCROLL || idObject == NativeMethods.OBJID_VSCROLL)
                    {
                        idObject = NativeMethods.OBJID_WINDOW;
                    }
                    el.DispatchEvents(eventId, idProp, idObject, idChild);
                }
                return;
            }

            if (idProp == ValuePattern.ValueProperty && eventId == NativeMethods.EVENT_OBJECT_VALUECHANGE)
            {
                NonClientItem    item      = idObject == NativeMethods.OBJID_HSCROLL ? NonClientItem.HScrollBar : NonClientItem.VScrollBar;
                WindowsScrollBar scrollBar = new WindowsScrollBar(hwnd, el, (int)item, idObject == NativeMethods.OBJID_HSCROLL ? NativeMethods.SB_HORZ : NativeMethods.SB_VERT);
                scrollBar.DispatchEvents(0, ValuePattern.ValueProperty, NativeMethods.OBJID_CLIENT, 0);
                return;
            }

            if (Misc.GetClassName(hwnd) == "ComboLBox")
            {
                el = (ProxyFragment)WindowsListBox.Create(hwnd, 0);
            }

            if (el != null)
            {
                el.DispatchEvents(eventId, idProp, idObject, idChild);
            }
        }