Returns:
- the name of nth option or sub-option found in the main menu of window.
- the name of nth option or sub-option found in a custom context menu (created with WINDEV or WINDEV Mobile).
In a loop, this function is used to enumerate the menu options of a window as well as the sub-options of a menu option.
i is int = 1
MenuName is string
MenuName = EnumMenu(MyWindow, 1) // Read the 1st menu of the window
WHILE MenuName <> ""
Trace(MenuName)
j is int = 1
NameSubMenu is string
NameSubMenu = EnumMenu(MenuName, j) // Read the 1st option of the menu
WHILE NameSubMenu <>""
Trace(" " + NameSubMenu)
j++ // Next option
NameSubMenu = EnumMenu(MenuName, j)
END
i++ // Next menu
MenuName = EnumMenu(MyWindow, i)
END
Syntax
<Result> = EnumMenu(<Parent object> , <Option number>)
<Result>: Character string
- Name of the option,
- Empty string ("") if <Parent object> corresponds to a menu option or if the enumeration is over.
The option name was defined in the window editor when creating the menu.
<Parent object>: Character string
- Name of the window containing the menus to list. This window must be opened when using this function.
- Name of the menu that contains the options to be listed.
<Option number>: Integer
Number of the option whose name is requested.
Remarks
A WLanguage error is displayed in the following cases:
- <Option number> is a negative integer.
- <Option number> is greater than the number of menu options + 1.
- <Parent object> is not a window, a menu or a menu option.
- <Parent object> is a window that is not opened. To list a menu found in a window that is not opened, use EnumSubElement.