示例#1
0
        // Static Create method called by the event tracker system
        internal static void RaiseEvents(IntPtr hwnd, int eventId, object idProp, int idObject, int idChild)
        {
            if (idObject != NativeMethods.OBJID_VSCROLL && idObject != NativeMethods.OBJID_HSCROLL)
            {
                ProxySimple el;
                if (IsInsideOfIPAddress(hwnd))
                {
                    el = new ByteEditBoxOverride(hwnd, idChild);
                }
                else
                {
                    el = new WindowsEditBox(hwnd, null, 0);

                    // If this is an Edit control inside of a Microsoft Spinner, need to treat the property
                    // changes for as property changes on the whole Microsoft Spinner, not on the element
                    // of the Microsoft Spinner.  Microsoft Spinner raise WinEvents on the Edit portion of
                    // the spinner and not the UpDown portion like the Win32 Spinner.
                    IntPtr hwndParent = NativeMethodsSetLastError.GetAncestor(hwnd, NativeMethods.GA_PARENT);
                    if (hwndParent != IntPtr.Zero)
                    {
                        // Test for spinner - Create checks if the element is a spinner
                        ProxySimple spinner = (ProxySimple)WinformsSpinner.Create(hwndParent, 0);
                        if (spinner != null)
                        {
                            el = spinner;
                        }
                    }
                }

                el.DispatchEvents(eventId, idProp, idObject, idChild);
            }
        }
示例#2
0
        private bool IsInsideOfSpinner()
        {
            IntPtr hwndParent = NativeMethodsSetLastError.GetAncestor(_hwnd, NativeMethods.GA_PARENT);

            if (hwndParent != IntPtr.Zero)
            {
                // Test for spinner - Create checks if the element is a spinner
                if (WinformsSpinner.Create(hwndParent, 0) != null)
                {
                    return(true);
                }
            }

            return(WindowsSpinner.IsSpinnerEdit(_hwnd));
        }
示例#3
0
        // Static Create method called by UIAutomation to create proxies for [....] controls.
        // returns null if unsuccessful
        internal static IRawElementProviderSimple Create(IntPtr hwnd, int idChild, int idObject)
        {
            // Currently there is an issue with CLR remoting that causes Accessible.CreateNativeFromEvent() to fail
            // for [....] controls.  Until that is resolved use AccessibleObjectFromWindow() instead.  It will
            // return a Native IAccessble and not a OleAcc implementaion.  [....] does provide a Native IAccessible.

            Accessible acc = null;

            if (Accessible.AccessibleObjectFromWindow(hwnd, idObject, ref acc) != NativeMethods.S_OK || acc == null)
            {
                return(null);
            }

            switch (acc.Role)
            {
            // ============================================================
            // WinformsSpinner controls are not identifiable by classname or
            // other simple properties.  The following case calls the
            // WinformsSpinner constructor which in turn tries to establish
            // the class of the control as a fact or returns null.
            case AccessibleRole.Combobox:
                return(WinformsSpinner.Create(hwnd, idChild, idObject));

            // ============================================================

            case AccessibleRole.SpinButton:
                return(WindowsUpDown.Create(hwnd, idChild, idObject));

            case AccessibleRole.Grouping:
                return(new WindowsButton(hwnd, null, WindowsButton.ButtonType.GroupBox, Misc.GetWindowStyle(hwnd) & NativeMethods.BS_TYPEMASK, acc));

            case AccessibleRole.StatusBar:
                WindowsStatusBar sb = new WindowsStatusBar(hwnd, null, 0, acc);
                if (sb == null)
                {
                    return(null);
                }
                return(idChild == NativeMethods.CHILD_SELF ? sb : sb.CreateStatusBarPane(idChild));

            default:
                break;
            }

            return(null);
        }