Skip to main content

Menu and MenuItem

A Menu class used to read the contents of a Windows Menu. It is normally created as a result of calling GetTopMenu.

The Menu class contains the following methods and properties:

Menu(IntPtr hMenu); // construct a Menu class from the given menu window handle
HandleRef Handle; // return the window handle
IList<MenuItem> Items // get a list of MenuItems in the menu
MenuItem FindMenuItem(int[] menuPath); // Find a MenuItem from a menu path as a list of integers
// where each integer is a menu indexMenuItem
FindMenuItem(string[] menuPath); // Find a MenuItem from a menu path as a list of strings

A MenuItem class used to read an individual menu item.

It is normally created as a result of calling FindMenu() or listing the items in a Menu class object.

The MenuItem class contains the following read-only properties:

uint ID; // the menu ID as an unsigned integer
bool IsChecked; // true if the menu item is checked
bool IsDisabled; // true if the menu item is disabled
bool IsGreyed; // true if the menu item is disable
dbool IsSeparator; // true if the item is a separator
string Name; // the text of the menu item
uint Offset;
Menu SubMenu; // any sub-menu of the item