Ejemplo n.º 1
0
        // Returns an item corresponding to the focused element (if there is one), or null otherwise.
        internal override ProxySimple GetFocus()
        {
            if (WindowsMenu.IsInSystemMenuMode())
            {
                // Since in system menu mode try to find point on the SystemMenu
                WindowsTitleBar titleBar = (WindowsTitleBar)CreateNonClientChild(NonClientItem.TitleBar);
                if (titleBar != null)
                {
                    ProxyFragment systemMenu = (ProxyFragment)titleBar.CreateTitleBarChild(WindowsTitleBar._systemMenu);

                    if (systemMenu != null)
                    {
                        // need to drill down ourself, since the FragmentRoot of the System Menu Bar will
                        // be NonClient area hence UIAutomation will not drill down
                        ProxySimple proxy = systemMenu.GetFocus();
                        if (proxy != null)
                        {
                            return(proxy);
                        }
                    }
                }
            }

            return(base.GetFocus());
        }
Ejemplo n.º 2
0
        private static IRawElementProviderSimple CreateSystemMenu(IntPtr hwnd)
        {
            NonClientArea   nonClientArea = new NonClientArea(hwnd);
            WindowsTitleBar titleBar      = (WindowsTitleBar)nonClientArea.CreateNonClientChild(NonClientItem.TitleBar);

            return(titleBar.CreateTitleBarChild(WindowsTitleBar._systemMenu));
        }
Ejemplo n.º 3
0
        private ProxySimple FindMenus(int x, int y)
        {
            if (WindowsMenu.IsInSystemMenuMode())
            {
                // Since in system menu mode try to find point on the SystemMenu
                WindowsTitleBar titleBar = (WindowsTitleBar)CreateNonClientChild(NonClientItem.TitleBar);
                if (titleBar != null)
                {
                    ProxyFragment systemMenu = (ProxyFragment)titleBar.CreateTitleBarChild(WindowsTitleBar._systemMenu);

                    if (systemMenu != null)
                    {
                        // need to drill down ourself, since the FragmentRoot of the System Menu Bar will
                        // be NonClient area hence UIAutomation will not drill down
                        ProxySimple proxy = systemMenu.ElementProviderFromPoint(x, y);
                        if (proxy != null)
                        {
                            return(proxy);
                        }
                    }
                }
            }
            else
            {
                // Not in system menu mode so it may be a Popup Menu, have a go at it
                ProxyFragment menu = CreateNonClientChild(NonClientItem.Menu);
                if (menu != null)
                {
                    // need to drill down ourself, since the FragmentRoot of the MenuBar will
                    // be NonClient area hence UIAutomation will not drill down
                    ProxySimple proxy = menu.ElementProviderFromPoint(x, y);
                    if (proxy != null)
                    {
                        return(proxy);
                    }

                    // We may have been on the Menu but not on a menu Item
                    return(menu);
                }
            }

            return(null);
        }
Ejemplo n.º 4
0
        internal ProxyHwnd CreateNonClientMenu()
        {
            // child windows don't have menus
            int style = WindowStyle;

            if (!Misc.IsBitSet(style, NativeMethods.WS_CHILD))
            {
                ProxyHwnd menuProxy = null;

                if (WindowsMenu.IsInSystemMenuMode())
                {
                    // Since in system menu mode try to find point on the SystemMenu
                    WindowsTitleBar titleBar = (WindowsTitleBar)CreateNonClientChild(NonClientItem.TitleBar);
                    if (titleBar != null)
                    {
                        menuProxy = (ProxyHwnd)titleBar.CreateTitleBarChild(WindowsTitleBar._systemMenu);
                    }
                }
                else
                {
                    IntPtr menu = UnsafeNativeMethods.GetMenu(_hwnd);
                    if (menu != IntPtr.Zero)
                    {
                        menuProxy = new WindowsMenu(_hwnd, this, menu, WindowsMenu.MenuType.Toplevel, (int)NonClientItem.Menu);
                    }
                }

                if (menuProxy != null)
                {
                    // if this menu is not visible its really not there
                    if (menuProxy.BoundingRectangle.Width != 0 && menuProxy.BoundingRectangle.Height != 0)
                    {
                        return(menuProxy);
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 5
0
        internal override void AdviseEventRemoved(AutomationEvent eventId, AutomationProperty [] aidProps)
        {
            // we need to create the menu proxy so that the global event for menu will be listened for.
            // This proxy will get advise of events needed for menus
            ProxyHwnd menuProxy = CreateNonClientMenu();

            if (menuProxy == null)
            {
                // If the window does not have a menu, it at least has a system menu.
                WindowsTitleBar titleBar = (WindowsTitleBar)CreateNonClientChild(NonClientItem.TitleBar);
                if (titleBar != null)
                {
                    menuProxy = (ProxyHwnd)titleBar.CreateTitleBarChild(WindowsTitleBar._systemMenu);
                }
            }

            if (menuProxy != null)
            {
                menuProxy.AdviseEventRemoved(eventId, aidProps);
            }

            base.AdviseEventRemoved(eventId, aidProps);
        }