MENU ADD STRING statement

Purpose

Add a string or separator to an existing menu.

Syntax

MENU ADD STRING, hMenu, txt$, id&, state& [, AT [BYCMD] pos&] [, CALL callback]

Remarks

A string may contain an optional command accelerator key, and also describe an equivalent keyboard accelerator combination.

hMenu 

Double-word or Long-integer variable containing the handle of the parent menu to which the string should be added.

txt$

Text to display in the parent menu. An ampersand (&) may be used in the string to make the following letter into a command accelerator (hot-key). The letter is underscored to signify that it is an accelerator. To create a horizontal separator instead of a text string, set txt$ = "-", id& = 0, state& = 0.

Keyboard accelerators, as described in the ACCEL ATTACH statement, can be indicated in the text of a menu item, for the reference of the user. To include a keyboard accelerator description in a menu string, separate it from the menu item text with a $TAB {CHR$(9)} character. For example:

MENU ADD STRING, hMenu, "Cu&t" & $TAB & "CTRL+X", id&, mstate&

id&

The unique numeric identifier for the menu item. When a menu item is selected, id& is sent to the parent dialog Callback Function to notify the dialog which option was selected.

state&

The initial state of the menu item. It can be one or more of the following, combined together with the OR operator to form a bitmask:

%MF_CHECKED

Place a checkmark next to the item.

%MF_DISABLED

Disable the menu item so that it cannot be selected.

%MF_ENABLED

Enable the menu item so that it can be selected.

%MF_GRAYED

Disable the menu item so that it cannot be selected, and draw it in a "grayed" state to indicate this.

%MF_UNCHECKED

Do not place a checkmark next to the item.

pos&

Optional position in the parent menu, where the menu item should be inserted. If the BYCMD option is used, the menu item is inserted prior to the menu item ID specified by pos&. Otherwise, the menu item is inserted at the physical pos& within the parent menu, where pos& = 1 for the first position, pos& = 2 for the second, and so on.

callback 

Optional name of a Callback Function that will be called when the menu item is selected.

Restrictions 

The application must call the MENU DRAW BAR statement whenever a menu changes, whether or not the menu is in a displayed dialog.

See also

Dynamic Dialog Tools, ACCEL ATTACH, Menus, MENU ADD POPUP, MENU ATTACH, MENU DELETE, MENU DRAW BAR, MENU GET STATE, MENU GET TEXT, MENU NEW BAR, MENU NEW POPUP, MENU SET STATE, MENU SET TEXT

Example

See Menu Example.