SETMENU "menustring[||menukey]", menulist
Description
SETMENU adds custom menus to the output window while a program is running. The required component, menustring, is the text that will be displayed in the menu item. The optional component, menukey, is the variable name that will be associated with the menu item. A menukey is separated from the menustring by two vertical bar characters(|), and should be used: to abbreviate a long menustring, when the menustring contains spaces or special characters, or to have multiple menu items with the same menustring. If no menukey is included, the value of menustring is used. The required component, menulist, is an array of string expressions that represent the menukeys of a submenu under a menu item. The menukey of the root menu of the output window is "Titlebar."
When a menu item is selected, an event is sent to the program. To respond to the event, include a PUBLIC SUB procedure with the following syntax:
SUB menukey_click()
'Do something in response
END SUB
Any menustring that begins with a hyphen character (-) will be added to the menu as an unselectable separator. Separators do not support submenus.
SETMENU can be used to change menus dynamically. Any time SETMENU is called, the affected menus are updated in the output window. If a menu item is modified, all of its submenu items are cleared.
To aid keyboard menu navigation, a character in a menustring may be underlined. Insert an ampersand character (&) in the menustring before a character to have it underlined.
To display a second column in a menu (i.e. to show keyboard accelerators), append a tab character (vbTAB) and the desired second column string to the menustring.
Example
REM SETMENU Example
'SETMENU adds custom menus to output window
DIM Menu
Menu = ARRAY("File", "Edit", "Help")
SETMENU "Titlebar", Menu
Menu = ARRAY("&New"&vbTAB&"Ctrl+n||New",_
"&Open" & vbTAB & "Ctrl+o||Open", _
"&Save" & vbTAB & "Ctrl+s||Save", _
"-", _
"&Recent Files||Recent", _
"-", _
"E&xit" & vbTAB & "Alt+F4||Exit")
SETMENU "File", Menu
Menu = ARRAY("&1 File 1||RF1", _
"&2 File 2||RF2", "&3 File 3||RF3", _
"&4 File 4||RF4")
SETMENU "Recent", Menu
SETMENU "Edit", ARRAY("Cut", "Copy","Paste")
Menu = ARRAY("About SETMENUExample...||ASE")
SETMENU "Help", Menu
SUB New_Click()
'Open a new file
END SUB
SUB Open_Click()
'Open an existing file
END SUB
Output