Exemplo n.º 1
0
        // Combo-specific events
        static private void RaiseEvents(IntPtr hwnd, int eventId, object idProp, int idObject, int idChild)
        {
            // ------------------------------------------------------/////////////////////////////////////
            //
            // Depending of the type of Combobox we will get different WinEvents
            //
            // Simple: No events
            //
            // DropDown: OBJ_STATECHANGE: for the dropbutton button (idChild == 2)
            // NOTE: that OBJECT_STATECHANGE will only be generated when user uses button to show the list
            // if user uses the button to hide the list, event will not be generated
            //
            // DropDownList: OBJ_STATECHANGE (same as above)
            //             : OBJECT_VALUECHANGE - when using the keyboard to navigate between list children
            //                                  - no need to handle it here, ListBox proxy will take care of that
            //
            // ------------------------------------------------------//////////////////////////////////////
            ProxySimple el = null;

            if (idProp is AutomationProperty && idProp == ExpandCollapsePattern.ExpandCollapseStateProperty)
            {
                // expand/collapse events are handled in WindowsListBox with the ComboLBox hwnd.
                // so just return here so we don't fire extraneous events
                return;
            }

            switch (idObject)
            {
            case NativeMethods.OBJID_CLIENT:
            {
                if (eventId == NativeMethods.EventObjectStateChange && idChild == 2)
                {
                    // event came for combobutton
                    // We will be getting 2 OBJECT_STATECHANGED event
                    // one with button state pressed and another normal
                    // both indicate the same invoke event
                    // hence second event is a duplicate of the first one and we need to filter it out
                    NativeMethods.COMBOBOXINFO cbInfo = new NativeMethods.COMBOBOXINFO(NativeMethods.comboboxInfoSize);

                    if (WindowsComboBox.GetComboInfo(hwnd, ref cbInfo) && Misc.IsBitSet(NativeMethods.STATE_SYSTEM_PRESSED, cbInfo.stateButton))
                    {
                        // The event could be for both the button and the combo
                        WindowsComboBox cb = (WindowsComboBox)Create(hwnd, 0);
                        cb.DispatchEvents(eventId, idProp, idObject, idChild);

                        el = cb.CreateComboButton();
                        el.DispatchEvents(eventId, idProp, idObject, idChild);
                        return;
                    }
                }
                el = (ProxySimple)Create(hwnd, 0);
                break;
            }
            }

            if (el != null)
            {
                el.DispatchEvents(eventId, idProp, idObject, idChild);
            }
        }
Exemplo n.º 2
0
        private static void RaiseEventsOnWindow(IntPtr hwnd, int eventId, object idProp, int idObject, int idChild)
        {
            AutomationProperty automationProperty = idProp as AutomationProperty;
            ProxySimple        el = null;

            if ((eventId == NativeMethods.EventObjectShow || eventId == NativeMethods.EventObjectHide) &&
                (automationProperty != null && automationProperty == ExpandCollapsePattern.ExpandCollapseStateProperty))
            {
                if (Misc.IsBitSet(Misc.GetWindowStyle(hwnd), NativeMethods.LBS_COMBOBOX))
                {
                    // List portion of combo: We'll hit it in the case when user hovers over it
                    NativeMethods.COMBOBOXINFO cbInfo = new NativeMethods.COMBOBOXINFO(NativeMethods.comboboxInfoSize);

                    if (WindowsComboBox.GetComboInfo(hwnd, ref cbInfo) && (cbInfo.hwndCombo != IntPtr.Zero))
                    {
                        WindowsComboBox cb = (WindowsComboBox)WindowsComboBox.Create(cbInfo.hwndCombo, 0);

                        if (!cb.IsSimpleCombo())
                        {
                            el = cb;
                        }
                    }
                }
            }

            if (el != null)
            {
                el.DispatchEvents(eventId, idProp, idObject, idChild);
            }
        }
Exemplo n.º 3
0
            // Same effect as a click on the drop down button
            void IInvokeProvider.Invoke()
            {
                // Ensure that the window and all its parents are enabled.
                Misc.CheckEnabled(_hwnd);

                if (!WindowsComboBox.GetDroppedState(_hwnd))
                {
                    WindowsComboBox.Expand(_hwnd);
                }
                else
                {
                    WindowsComboBox.Collapse(_hwnd);
                }
            }
Exemplo n.º 4
0
        internal static IRawElementProviderSimple Create(IntPtr hwnd, int idChild)
        {
            bool          parentedByCombo = false;
            ProxyFragment parent          = null;
            int           item            = 0;

            try
            {
                int style = Misc.GetWindowStyle(hwnd);
                // If can not get windows style the hwnd is bad so do not create a proxy for it.
                if (style == 0)
                {
                    return(null);
                }

                if (Misc.IsBitSet(style, NativeMethods.LBS_COMBOBOX))
                {
                    // List portion of combo box
                    NativeMethods.COMBOBOXINFO cbInfo = new NativeMethods.COMBOBOXINFO(NativeMethods.comboboxInfoSize);

                    if (WindowsComboBox.GetComboInfo(hwnd, ref cbInfo) && (cbInfo.hwndCombo != IntPtr.Zero))
                    {
                        parent          = (ProxyFragment)WindowsComboBox.Create(cbInfo.hwndCombo, 0);
                        parentedByCombo = true;
                        item            = (int)WindowsComboBox.ComboChildren.List;
                    }
                }
            }
            catch (ElementNotAvailableException)
            {
                return(null);
            }

            WindowsListBox listbox = new WindowsListBox(hwnd, parent, item, parentedByCombo);

            if (idChild == 0)
            {
                return(listbox);
            }
            else
            {
                return(listbox.CreateListboxItem(idChild - 1));
            }
        }
Exemplo n.º 5
0
        private bool IsInsideOfCombo()
        {
            IntPtr hwndParent = NativeMethodsSetLastError.GetAncestor(_hwnd, NativeMethods.GA_PARENT);

            if (hwndParent == IntPtr.Zero)
            {
                return(false);
            }

            // Test for combo
            NativeMethods.COMBOBOXINFO cbInfo = new NativeMethods.COMBOBOXINFO(NativeMethods.comboboxInfoSize);

            if (WindowsComboBox.GetComboInfo(hwndParent, ref cbInfo) && cbInfo.hwndItem == _hwnd)
            {
                return(true);
            }

            return(false);
        }