Reference Manual - Table of Contents Menus This section describes commands and functions for creating pulldown menus for the menubar. Items created in the menu bar can be pointed to SUB Procedures, that will be called when this item is selected by the user.
Visual MacStandardBasic automatically creates a menu template (stationary) when a New Project is created. The commands creating this menu template are in a Sub Procedure in Form1 called CreateMyMenus. You can change this procedure to your desired application's menu.
Command Summary:
MenuAdd menu#, title$, Sub
MenuAddItem menu#, text$, cmdLetter$, Sub
MenuApple
MenuBlank
MenuClear
MenuDelete menu#
MenuDeleteItem menu#, menuitem#
MenuDesk
MenuDisable menu#, menuitem#
MenuEnable menu#, menuitem#
MenuFonts menu#
MenuInsertItem menu#, menuitem#, text$, cmdLetter$, Sub
MenuMark menu#, menuitem#, mark
MenuRedraw
MenuText menu#, menuitem#, text$
SubMenu var, menu#, menuItem#, SubFunction Summary:
var = MenuCount ( menu# )
var = MenuMark ( menu#, menuitem# )
var$ = MenuText ( menu#, menuitem# )
MenuAdd menu#, title$, Sub
This command will add a pull-down menu to the menubar. The value of 1 is for the Apple Menu (use the AppleMenu command to add this menu), 2 for next menu (which is normally a File menu), and so on.
menu# - This should be a numeric expression that contains a value that is used to designate which menu to add. It should be 2 or greater.
title$ - This is a string expression designating the menu title.
Sub - This is a reference to the a SUB procedure that will be called when this a menu item is selected. Use NONE instead of a Sub procedure name to indicate no action should be performed.
Example: ' Let's create some simple menus MenuApple MenuAddItem 1, "About Program", "", AboutMyProgram MenuDesk 'Append on the rest of Apple Menu stuff MenuAdd 2, "File", None MenuAddItem 2, "Quit", "Q", QuitMyApp
MenuAddItem menu#, text$, cmdLetter$, Sub
This command will add a menu item to the specified pull-down menu.
menu# - This should be a numeric expression that contains a value that is used to designate menu to add the item to.
text$ - This is a string expression designating the menu title. Use "-" if you want to add a separator bar item.
cmdLetter$ - This is a string expression whose first letter will be used as command key equivalent for the menu item. Use an empty string to designate that there is no command key equivalent.
Sub - This is a reference to the a SUB procedure that will be called when this menu item is selected. Use NONE instead of a Sub procedure name to indicate no action should be performed.
Example: ' Let's create some simple menus MenuApple MenuAddItem 1, "About Program", "", AboutMyProgram MenuDesk 'Append on the rest of Apple Menu stuff MenuAdd 2, "File", None ' The letter O will be the command key for the Open menu item MenuAddItem 2, "Open", "O", OpenMyFile MenuAddItem 2, "-", "", None ' Adds a separator line ' The letter Q will be the command key for the Quit menu item MenuAddItem 2, "Quit", "Q", QuitMyApp
MenuApple
This command creates a Apple menu in the first menubar position. The menubar should have no menus when this command is used. You can use the MenuClear command to empty the menubar of menus. Many programmers add an About menu item to allow the displaying of a copyright information box. Use the MenuDesk command after this to add Desk Accessory Menu folder items that will be appended to your Apple Menu.
MenuBlank
This command will blank the menubar but will not remove the menus from the menubar.
MenuClear
This command removes all current menus from the menu bar. This includes all submenus that were created.
MenuDelete menu#
This command will remove a menu from the menubar.
menu# - This should be a numeric expression that contains a value that is used to designate which menu whould be removed from the menubar.
MenuDeleteItem menu#, menuitem#
This command will remove a menu item from the specified menu.
menu# - This should be a numeric expression that contains a value that is used to designate menu to remove an item.
menuItem# - This should be a numeric expression that is used to designate the menu item that will be deleted
MenuDesk
This command adds the items from the Systems Menu Folder to an Apple Menu. Use this command after you have created an Apple Menu.
MenuDisable menu#, menuitem#
This command will disable a menuitem in the specified menu.
menu# - This should be a numeric expression that contains a value that is used to designate which menu in the menubar to use.
menuItem# - This should be a numeric expression that contains a value that is used to designate the menu item that will be disabled.
MenuEnable menu#, menuitem#
This command will enable a menu item in the specified menu.
menu# - This should be a numeric expression that contains a value that is used to designate which menu in the menubar to use.
menuItem# - This should be a numeric expression that contains a value that is used to designate the menu item that will be enabled.
MenuFonts menu#
This command will adds a list all fonts available to the the specified menu. The number of font names added with depend on how many fonts are available on the Macintosh the runtime application is run on.
menu# - This should be a numeric expression that contains a value that is used to designate which menu in the menubar to use.
MenuInsertItem menu#, menuItem#, text$, cmdLetter$, Sub
This command will insert a menu item at a specified position to the specified menu. All other menu items greater than and equal to the menuItem# will be pushed down one position.
menu# - This should be a numeric expression that contains a value that is used to designate which menu to insert the item in.
menuItem# - This should be a numeric expression that contains a value that is used to designate position the this menu item will inserted at.
cmdLetter$ - This is a string expression whose first letter will be used as command key equivalent for the menu item. Use an empty string to designate that there is no command key equivalent.
text$ - This is a string expression designating the menu title.
Sub - This is a reference to the a SUB procedure that will be called when this menu item is selected. Use NONE instead of a Sub procedure name to indicate no action should be performed.
MenuMark menu#, menuItem#, mark
This command will allow you to set or remove a character as the item mark of the specified menu item. Item marks such as a check mark, bullet, diamond, apple, etc can be used to designate a status of a menu item.
menu# - This should be a numeric expression that contains a value that is used to designate which menu to the item is in.
menuItem# - This should be a numeric expression that contains a value that is used to designate item in the menu.
mark - This is a mumeric value designating if item should be the new menu item text.
Some common values for mark
0 = No mark
17 = Keyboard command key symbol
18 = Checkmark
19 = Diamond
20 = Apple symbol
165 = Bullet dot
195 = Square root mark
200 = >>
215 = Hollow diamond
MenuRedraw
This command will immediately redraw the menubar.
MenuText menu#, menuItem#, text$
This command will allow you to change the text of an existing menu item.
menu# - This should be a numeric expression that contains a value that is used to designate which menu to the item is in.
menuItem# - This should be a numeric expression that contains a value that is used to designate the item in the menu.
text$ - This is a string expression designating the new menu item text.
SubMenu var, menu#, menuItem#, Sub
This command will insert a sub-menu to a specified menu item position to the menu. Sub-menus are part of the hierarchical menu system, that allows for an entire menu to be attached to a menu item from another menu.
var - This should be a numeric variable that will contain a value the should be used to reference the submenu. This will equal -1 if an error occurred creating the submenu.
menu# - This should be a numeric expression that contains a value that is used to designate which menu to insert the submenu in.
menuItem# - This should be a numeric expression that contains a value that is used to designate the menu item will given a submenu.
Sub - This is a reference to the a SUB procedure that will be called when this menu item is selected. Use NONE instead of a Sub procedure name to indicate no action should be performed.
var = MenuCount( menu# )
This function returns the value that indicates how many menu items there are in the specified menu.
menu# - This should be a numeric expression that contains a value that is used to designate the desired menu.
var = MenuMark( menu#, menuItem# )
This function returns the value of a item mark of the specified menu item. Item marks such as a check mark, bullet, diamond, apple, etc can be used to designate a status of a menu item.
menu# - This should be a numeric expression that contains a value that is used to designate which menu the item is in.
menuItem# - This should be a numeric expression that contains a value that is used to designate item in the menu.
Some return values
0 = No mark
17 = Keyboard command key symbol
18 = Checkmark
19 = Diamond
20 = Apple symbol
165 = Bullet dot
195 = Square root mark
200 = >>
215 = Hollow diamond
var$ = MenuText( menu#, menuItem# )
This returns a text string value that represents the text of an existing menu item.
menu# - This should be a numeric expression that contains a value that is used to designate which menu to the item is in.
menuItem# - This should be a numeric expression that contains a value that is used to designate item in the menu.