Beispiel #1
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));
        }
        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
        // This method will set the hot item since toolbar buttons can't have focus
        internal override bool SetFocus()
        {
            // Get current focus...
            WindowsToolbar toolbar = (WindowsToolbar)_parent;
            ToolbarItem    focused = toolbar.GetFocus() as ToolbarItem;

            // ... check for no current focus or currently focused item is not the one we want...
            if (focused == null || _item != focused._item)
            {
                //... set the focus

                /*
                 *                  // should this go to parent window?
                 *                  if ( NativeMethods.DefWindowProc( _hwnd, NativeMethods.WM_SETFOCUS, IntPtr.Zero, IntPtr.Zero ) != IntPtr.Zero )
                 *                  {
                 *                      return false;
                 *                  };
                 */
                Misc.ProxySendMessage(_hwnd, NativeMethods.TB_SETHOTITEM, new IntPtr(_item), IntPtr.Zero);
            }

            return(true);
        }