Menu class

This class refers to menus, menu items and pop-up menus.

Creating menus and menu items

caption is an array that describe the whole structure of the menu. Each item can be a string or an array. Possible values for each item are:

Array element




A menu title



A separator



A menu item

array(ID_OPEN, "&Open...\tCtrl+O", "", "menu_open.bmp", "Ctrl+O")

A menu item is an array that contains the following elements:

Identifier: The integer value associated with the menu item.
Caption: The menu item caption. Prepend the character "&" to the character that is to be used as the menu item access key. This character will appear underlined. Use "\t" (the tab character) to separate the actual caption from the accelerator description.
Hint: A hint, or one-line help, that will appear in the status bar when the menu item is selected.
Image: The name of a bitmap or icon to be attached to the menu item;
Accelerator: A string like "Ctrl+S", "Alt+Ctrl+Shift+F12", "F1", "O", etc. See the topic Accel class for more information.


// Create main menu
$mainmenu = wb_create_control($mainwin, Menu, array( 
       array(ID_NEW,     "&New\tCtrl+N",     "", PATH_RES . "menu_new.bmp",  "Ctrl+N"),
       array(ID_OPEN,    "&Open...\tCtrl+O", "", PATH_RES . "menu_open.bmp", "Ctrl+O"),
       null,             // separator                      
       array(ID_SAVE,    "&Save\tCtrl+S",    "", PATH_RES . "menu_save.bmp", "Ctrl+S"),
       array(ID_SAVEAS,  "Save &As..."),
       null,             // separator
       array(IDCLOSE,    "E&xit\tAlt+F4",    "", PATH_RES . "menu_exit.bmp"),
       array(ID_HELP,    "&Help topics\tF1", "", PATH_RES . "menu_help.bmp",  "F1"),
       null,             // separator
       array(ID_WEBSITE, "&Web site"),
       null,             // separator
       array(ID_ABOUT,   "About...")

See also

Control classes