MENU dialog element

Top  Previous  Next

Syntax:

 

DIALOG ADD,MENU,<menu name> {,<item 1>|<item 2>|...}

Description:

 

This dialog element adds a pull-down menu to the window. Successive pull-down menus are created by each DIALOG ADD,MENU command.

If no <item description> parameters are given, a menu with the name <menu name> will be created, which will generate a <name>MENU event when it is clicked.

The next parameter define the pull-down menu items. If this parameter is specified, no event is generated when the menu bar item <menu name> is clicked, but an <item>MENU event is generated when a pull-down menu item is selected. The <item> part of the event name is normally the text of the menu item, unless a separate name has been specified.

Menu items are described using the form <item name>;<shortcut key>;<bitmap>. Only <item name> is mandatory, and must be unique. Line separators in a menu may be specified by using a dash '-' in place of a name. Menu items are separated by vertical bar '|' characters. [VDS5] See note below.

<item name> specifies the name and text of the menu item. It takes the form <name>:<text> where <name> and its separating colon are optional. Menu items do not usually have names. If <name> is omitted then a <text>MENU event is generated when the menu item is clicked. If <name> is specified, then the event will be <name> instead. If a menu item is named then it is possible to change the menu item text and enable/disable it using the DIALOG SET command. (Tip: Choose a name ending in MENU for menu items.)
<shortcut key> can specify an additional shortcut key or key combination that can be used to invoke the menu. This is defined using the standard syntax for shortcuts, for example: F10, Shift+F8, Ctrl+C.
<bitmap> can specify an optional 16x16 pixel bitmap that will be displayed to the left of the menu caption. The filename may be prefixed by a # character if the bitmap file is to be included in the compiled executable file as a resource.

A menu item may be enabled or disabled or show a check box, depending on the current context of the program. To specify whether a menu item should be enabled or disabled, or checked, either:

the menu item should be named, as described above, so that DIALOG ENABLE and DIALOG DISABLE can be used.
registry values must be set in the program's default registry key to show the required state. The names of these registry values must match the text of the corresponding menu item. These registry values will be checked whenever the drop-down menu is displayed, so that the menu is shown in the correct context. To show a check box against a menu item, use the command: REGISTRY WRITE, DEFAULT, , <name>,1. To clear the check box, set the value <name> to null, or delete the value. To disable a menu item use the command: REGISTRY WRITE, DEFAULT, MenuCtrl, <name>, X. To re-enable the menu item, set the value <name> to null, or delete it.

The registry method is not used if the menu item has been named.

Note 1: Once a pull-down menu has been added to a dialog it cannot be removed or hidden. The DIALOG verbs CLEAR, HIDE, SHOW and REMOVE cannot be used with menus.

Note 2: If an ampersand '&' appears in a menu item name, the character that follows it will be shown underlined (not in Windows XP theme style) and the key combination Alt+<underlined character> can automatically be used as a shortcut for that menu. Care should be taken to ensure that the shortcuts chosen are unique. This is a standard feature of Windows.

[VDS5] In VDS 5, each pull-down menu item is defined using a separate parameter to the DIALOG ADD command, and vertical bars are used to separate the shortcut key (if defined) from the menu text. The syntax has been changed to allow menu definitions to be built up in a variable, and for consistency with the syntax used for popup menus. In VDS 5, menu items cannot be named, and DIALOG SET, ENABLE and DISABLE cannot be used with them.

Styles:

Styles cannot be applied to a menu.

See also: