Alter Menu Bar statement - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

Adds or removes menus from the menu bar.

Syntax

Alter Menu Bar { Add | Remove } 
	{ menuname | ID menu_id } 
	[ , { menuname | ID menu_id } ... ] 

menuname is the name of an available menu (e.g., "File")

menu_id is a standard menu ID from one to fifteen; one represents the File menu.

Things to remember when using this command with MapInfo Pro 64-bit:
  1. In MapInfo Pro 64-bit, this command adds or removes a menu from the menu group on the LEGACY tab.
  2. The following sub-menus would also be treated as individual dropdown in a menu group:
    1. Open Web Service
    2. Find Selection
    3. Oracle Workspace Tools
    4. Maintenance
    5. Raster
    6. Licensing
    7. Tile Serve Maps

Description

The Alter Menu Bar statement adds or removes one or more menus from the current menu bar.

The menuname parameter is a string representing the name of a menu, such as "File" or "Edit". The menuname parameter may also refer to the name of a custom menu created by a Create Menu statement (see example below)

Note: If the application is running on a non-English language version of MapInfo, and if the menu names have been translated, the Alter Menu Bar statement must specify the translated version of the menu name. However, each of MapInfo Pro's standard menus (File, Edit, etc.) also has a menu ID, which you can use regardless of whether the menu names have been translated. For example, specifying ID 2 always refers to the Edit menu, regardless of whether the menu has been translated.

For a list of MapInfo Pro's standard menu names and their corresponding ID numbers, see Alter Menu statement.

Adding Menus to the Menu Bar

An Alter Menu Bar Add statement adds a menu to the right end of the menu bar. If you need to insert a menu at another position on the menu bar, use the Create Menu Bar statement to redefine the entire menu bar.

If you add enough menus to the menu bar, the menu bar wraps down onto a second line of menu names.

Removing Menus from the Menu Bar

An Alter Menu Bar Remove... statement removes a menu from the menu bar. However, the menu remains part of the "pool" of available menus. Thus, the following pair of statements would first remove the Query menu from the menu bar, and then add the Query menu back onto the menu bar (at the right end of the bar).

Alter Menu Bar Remove "Query" 
Alter Menu Bar Add "Query" 

After an Alter Menu Bar Remove... statement removes a menu, MapInfo Pro ignores any hotkey sequences corresponding to items that were on the removed menu. For example, a MapInfo Pro user might ordinarily press Ctrl+O to bring up the File menu's Open dialog box; however, if an Alter Menu Bar Remove statement removed the File menu, MapInfo Pro would ignore any Ctrl+O key-presses.

Example

The following example creates a custom menu, called DataEntry, then uses an Alter Menu Bar Add statement to add the DataEntry menu to MapInfo Pro's menu bar.

Declare Sub addsub
Declare Sub editsub
Declare Sub delsub
Create Menu "DataEntry" As 
	"Add" Calling addsub,
	"Edit" Calling editsub,
	"Delete" Calling delsub
'Remove the Window menu and Help menu
Alter Menu Bar Remove ID 6, ID 7 
'Add the custom menu, then the Window & Help menus
Alter Menu Bar Add "DataEntry", ID 6, ID 7 

Before adding the custom menu to the menu bar, this program removes the Help menu (menu ID 7) and the Window menu (ID 6) from the menu bar. The program then adds the custom menu, the Window menu, and the Help menu to the menu bar. This technique guarantees that the last two menus will always be Window and Help.

See Also:

Alter Menu statement, Alter Menu Item statement, Create Menu statement, Create Menu Bar statement, Menu Bar statement