CreateMenu ( text$,menu_id,parent_menu )
Parameters
|
text$ - item label; put & before a letter to make it the underlined access key; an empty string creates a separator line menu_id - your own tag for the item, delivered in EventData when it is picked parent_menu - menu to add the item to: a window's menu bar root from WindowMenu, a popup root from CreatePopupMenu, or another menu item (which then becomes a submenu) |
Description
|
Adds a menu item and returns its handle. Requires Extended language mode. Menus are built one item at a time. Items created on WindowMenu(window) become the top-level headings (File, View); items created on those become their commands; and any item that is given children turns into a submenu automatically. The same command fills popup menus made with CreatePopupMenu. When the user picks an item, a menu-action event ($1001) arrives on the shared event queue with your menu_id tag in EventData - EventSource is 0 for menu actions, so the tag is how you identify the command. Pick distinct tags for real commands (101, 102, 199...) and just use 0 for headings that only hold submenus. The tag is your own number and has nothing to do with the returned handle, which is what CheckMenu, EnableMenu and SetMenuText operate on. Menu text is UTF-8. After building or changing a window's menu bar, call UpdateWindowMenu to make the native bar redraw; popup menus need no update because their native menu is built fresh each time they are shown. See it working in the menus and events sample and the world editor shell sample. See also: WindowMenu, UpdateWindowMenu, CreatePopupMenu, CheckMenu, EnableMenu, SetMenuText. |
Index