[id] = CreateMenu(id, table)
Menu
tag in the @DISPLAY
preprocessor command or in the CreateDisplay() call.
You have to pass an identifier for the new menu strip or Nil. If you
pass Nil, CreateMenu()
will return a handle to the new menu strip
which you can then use to refer to this menu strip.
You also need to pass a table containing the actual menu tree definition to this function. Menus are defined as a tree structure that is composed of a master table that contains various subtables. See MENU for a detailed description of menu tree tables.
This command is also available from the preprocessor: Use @MENU to create menu strips at startup time!
CreateMenu(1, { {"File", { {"New", ID = "new"}, {"Open...", ID = "open"}, {""}, {"Close", ID = "close", Flags = #MENUITEM_DISABLED}, {""}, {"Save", Flags = #MENUITEM_DISABLED, Hotkey = "S"}, {"Compress", ID = "cmp", Flags = #MENUITEM_TOGGLE}, {""}, {"Export image...", { {"JPEG...", ID = "jpeg"}, {"PNG...", ID = "png"}, {"BMP...", ID = "bmp"}}}, {""}, {"Dump state", ID = "dump"}, {""}, {"Quit", ID = "quit", Hotkey = "Q"}}}, {"Edit", { {"Cut", ID = "cut"}, {"Copy", ID = "copy"}, {"Paste", ID = "paste"}}}, {"?", { {"About...", ID = "about"}}} }) SetDisplayAttributes({Menu = 1})The code above creates a menu strip and attaches it to the current display.