Beispiel #1
0
        // ------------------------------------------------------
        //
        // Internal Methods
        //
        // ------------------------------------------------------

        #region Internal Methods

        // Create a WindowsToolbar instance.  Needs to be internal because
        // ApplicationWindow pattern needs to call this so needs to be internal
        internal ProxySimple CreateToolbarItem(int item)
        {
            NativeMethods.TBBUTTON tbb = new NativeMethods.TBBUTTON();

            // During the FocusChanged WinEvent (EVENT_OBJECT_FOCUS),
            // some "ToolbarWindow32" children report an item ID (child id)
            // of 0x80000001, 0x80000002, etc. instead of 1, 2, etc.
            // However, when created as children of the parent toolbar,
            // these same items are assigned IDs of 1, 2, etc.
            // Therefore, map negative item IDs of the form 0x80000001,
            // 0x80000002, etc. to 1, 2, etc.
            item = (int)(~0x80000000 & (uint)item);

            if (!XSendMessage.GetItem(_hwnd, item, ref tbb))
            {
                // If failed to get button infromation the button must not exist, so return null.
                return(null);
            }

            if (Misc.ProxySendMessageInt(_hwnd, NativeMethods.TB_ISBUTTONHIDDEN, new IntPtr(tbb.idCommand), IntPtr.Zero) == 0)
            {
                Accessible acc = Accessible.CreateNativeFromEvent(_hwnd, NativeMethods.OBJID_CLIENT, item + 1);
                if (acc != null)
                {
                    if (acc.Role == AccessibleRole.MenuItem)
                    {
                        return(new ToolbarItemAsMenuItem(_hwnd, this, item, tbb.idCommand, acc));
                    }
                }

                return(new ToolbarItem(_hwnd, this, item, tbb.idCommand));
            }
            return(null);
        }
Beispiel #2
0
        internal static IRawElementProviderSimple Create(IntPtr hwnd, int idChild)
        {
            WindowsToolbar wtv = null;

            // By calling Accessible.CreateNativeFromEvent() instead of AccessibleObjectFromWindow() only controls with a native
            // implementation of IAccessible will be found.  OleAcc will not create a IAccessible proxy, since
            // Accessible.CreateNativeFromEvent() by passes OleAcc by sending a WM_GETOBJECT directly to the control and creating
            // IAccessible from the return, if it can.
            Accessible acc = Accessible.CreateNativeFromEvent(hwnd, NativeMethods.OBJID_CLIENT, NativeMethods.CHILD_SELF);

            if (acc != null)
            {
                AccessibleRole role = acc.Role;
                if (role == AccessibleRole.MenuBar || role == AccessibleRole.MenuPopup)
                {
                    wtv = new WindowsToolbarAsMenu(hwnd, null, 0, acc);
                }
            }

            if (wtv == null)
            {
                wtv = new WindowsToolbar(hwnd, null, 0);
            }

            return(idChild == 0 ? wtv : wtv.CreateToolbarItem(idChild - 1));
        }
Beispiel #3
0
        // Returns an item corresponding to the focused element (if there is one), or null otherwise.
        internal override ProxySimple GetFocus()
        {
            int focusIndex = Misc.ProxySendMessageInt(_hwnd, NativeMethods.TB_GETHOTITEM, IntPtr.Zero, IntPtr.Zero);

            if (focusIndex >= 0)
            {
                Accessible acc = Accessible.CreateNativeFromEvent(_hwnd, NativeMethods.OBJID_CLIENT, NativeMethods.CHILD_SELF);
                if (acc != null)
                {
                    AccessibleRole role = acc.Role;
                    if (role == AccessibleRole.MenuBar || role == AccessibleRole.MenuPopup)
                    {
                        return(new WindowsToolbarAsMenu(_hwnd, this, focusIndex, acc));
                    }
                }

                return(new WindowsToolbar(_hwnd, this, focusIndex));
            }
            else
            {
                return(null);
            }
        }