UI Automation Support for the Menu Control Type

This topic provides information about Microsoft UI Automation support for the Menu control type.

A menu control allows hierarchal organization of elements associated with commands and event handlers. In a typical Microsoft Windows application, a menu bar contains several menu buttons (such as File, Edit, and Window), and each menu button displays a menu. A menu contains a collection of menu items (such as New, Open, and Close), which can be expanded to display additional menu items or to perform a specific action when clicked.

The following sections define the required UI Automation tree structure, properties, control patterns, and events for the Menu control type. The UI Automation requirements apply to all menu controls, whether Microsoft Windows Presentation Foundation (WPF), Microsoft Win32, or Windows Forms.

This topic contains the following sections.

Required UI Automation Tree Structure

The following table depicts the control view and the content view of the UI Automation tree that pertains to menu controls and describes what can be contained in each view. For more information about the UI Automation tree, see UI Automation Tree Overview.

Control View Content View
  • Menu
    • MenuItem (1 or many)
  • Not applicable (unless the menu control is a context menu that is a parent of an object that is not a menu item)
    • MenuItem (1 or many)

Menu controls always appear in the control view and the content view of the UI Automation tree. Menu control types should appear under the control that their information is referring to. UI Automation clients must listen for UIA_MenuOpenedEventId to ensure that they consistently obtain information conveyed by menu controls. Context menu controls are a special case. They appear as children of the Desktop.

Required UI Automation Properties

The following table lists the UI Automation properties whose value or definition is especially relevant to the Menu control type. For more information about UI Automation properties, see UI Automation Properties for Clients.

UI Automation Property Value Notes
UIA_ControlTypePropertyId Menu This value is the same for all UI frameworks.
UIA_IsContentElementPropertyId FALSE The menu control is not included in the content view of the UI Automation tree.
UIA_IsControlElementPropertyId TRUE The menu control is always included in the control view of the UI Automation tree.
UIA_LabeledByPropertyId NULL No label.
UIA_NamePropertyId Not Supported The menu control does not require a Name property to be set.

Required UI Automation Control Patterns

There are no required control patterns for the Menu control type.

Required UI Automation Events

Menu controls must raise the UIA_MenuOpenedEventId event when they appear on the screen. The UIA_MenuOpenedEventId event will include the text of the control. The UIA_MenuClosedEventId event must be raised when a menu disappears from the screen.

The following table lists the UI Automation events that menu controls are required to support. For more information on events, see UI Automation Events Overview.

UI Automation Event Notes
UIA_AutomationFocusChangedEventId None
UIA_BoundingRectanglePropertyId property-changed event. None
UIA_IsEnabledPropertyId property-changed event. If the control supports the IsEnabled property, it must support this event.
UIA_IsOffscreenPropertyId property-changed event. If the control supports the IsOffscreen property, it must support this event.
UIA_MenuClosedEventId None
UIA_MenuOpenedEventId None
UIA_StructureChangedEventId None

Related Topics

Community Additions

Show: