Alter Menu 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 items from an existing menu.

Syntax 1

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

Where each menudef defines a menu item, according to the syntax:

	newmenuitem 
	[ ID menu_item_id ] 
	[ HelpMsg help ] 
	[ { Calling handler | As menuname } ] 

menuname is the name of an existing menu (for example, "File").

menu_id is a standard integer menu ID from 1 to 64; 1 represents the File menu.

newmenuitem is a string, the name of an item to add to the specified menu.

menu_item_id is a custom integer menu item identifier, which can be used in subsequent Alter Menu Item statements.

help is a string that will appear on the status bar while the menu item is highlighted.

handler is the name of a procedure, or a code for a standard menu command (e.g., M_FILE_NEW), or a special syntax for handling the menu event by calling OLE or DDE. If you specify a command code for a standard MapInfo Pro Show/Hide command (such as M_WINDOW_STATISTICS), the newmenuitem string must start with an exclamation point and include a caret (^), to preserve the item's Show/Hide behavior. For more details on the different types of handler syntax, see the Create Menu statement.

Syntax 2

Alter Menu { menuname | ID menu_id }
	Remove { handler | submenuname | ID menu_item_id } 
		[ , { handler | submenuname | ID menu_item_id } ... ] 

menuname is the name of an existing menu.

menu_id is an integer menu ID from 1 to 64; 1 represents the File menu.

handler is either the name of a sub procedure or the code for a standard MapInfo Pro command.

submenuname is the name of a hierarchical submenu to remove from the specified menu.

menu_item_id is a custom integer menu item identifier.

Things to remember when using this command with MapInfo Pro 64-bit:
  1. If the same menu is added at two different places, then only the last one added can be modified using this command.
  2. If any of MapInfo Pro's predefined menus are added to a drop down, this command would only modify the one in menu group.

Description

The Alter Menu statement adds menu items to an existing menu or removes menu items from an existing menu.

The statement can identify the menu to be modified by specifying the name of the menu (e.g., "File") through the menuname parameter.

If the menu to be modified is one of the standard MapInfo Pro menus, the Alter Menu statement can identify which menu to alter by using the ID clause. The ID clause identifies the menu by a number from 1 to 64. The following table lists the names and ID numbers of all standard MapInfo Pro menus.

Table 1. ID Numbers for Menus
Menu Name Define ID Description
File M_FILE 1 File menu.
Edit M_EDIT 2 Edit menu.
Search M_SEARCH 3 Search menu.
Query M_QUERY 3 Query menu.
Programs M_PGM 4 Programs menu.
Tools M_TOOLS 4 Tools menu.
Options M_OPTIONS 5 Options menu.
Window M_WINDOW 6 Window menu.
Help M_HELP 7 Help menu.
Browse M_BROWSE 8 Browse menu. Ordinarily, this only appears when a Browser window is the active window.
Map M_MAP 9 Map menu. Ordinarily, this menu is only available when a Map window is active.
Layout M_LAYOUT 10 Layout menu. Available when a Layout window is active.
Graph M_GRAPH 11 Graph menu. Available when a Graph window is active.
MapBasic M_MAPBASIC 12 MapBasic menu. Available when the MapBasic window is active.
Redistrict M_REDISTRICT 13 Redistrict menu. Available when a Districts Browser is active.
Objects M_OBJECTS 14 Objects menu.
Table M_TABLE 15 Table menu.
Open Web Service M_OPEN_WEBSERVICE 39 Open Web Service submenu on the File menu.
Find Selection M_FIND_SELECTION 40 Find Selection submenu on the Query menu.
Oracle Workspace Tools M_ORACLE_TOOLS 41 Oracle Workspace Tools submenu on the Table menu.
Maintenance M_TAB_MAINTENANCE 42 Maintenance submenu on the Table menu.
Raster M_TAB_RASTER 43 Raster submenu on the Table menu.
Licensing M_LICENSING 44 Licensing submenu on the Help menu.
Tile Server Maps M_TILESERVER 45 Tile Server submenu on the File menu.
Legend Designer M_LEGEND_DESIGNER 49 Legend menu.
Layout Designer M_LAYOUT_DESIGNER 51 Layout menu.

The following are shortcut menus, which appear when the user clicks with the right mouse button.

Table 2. ID Numbers for Shortcut Menus
Menu Name Define ID Description
DefaultShortcut M_SHORTCUT_DFLT 16 The default shortcut menu. This menu appears if the user right-clicks on a window that does not have its own shortcut menu defined.
MapperShortcut M_SHORTCUT_MAPPER 17 The Map window shortcut menu.
BrowserShortcut M_SHORTCUT_BROWSER 18 The Browse window shortcut menu.
LayoutShortcut M_SHORTCUT_LAYOUT 19 The Layout window shortcut menu.
GrapherShortcut M_SHORTCUT_GRAPHER 20 The Graph window shortcut menu. This menu contains options for creating graphs.
CmdShortcut M_SHORTCUT_CMD 21 The MapBasic window shortcut menu.
RedistrictShortcut M_SHORTCUT_REDISTRICTER 22 The Redistricting shortcut menu; available when the Districts Browser is active.
LegendShortcut M_SHORTCUT_LEGEND 23 The Legend window shortcut menu.
GrapherShortcut M_SHORTCUT_GRAPHTDG 24 The Graph window shortcut menu. This menu contains options for formatting graphs already created.
3DMapShortcut M_SHORTCUT_3DMAP 25 The 3D Map window shortcut menu.
MessageWinShortcut M_SHORTCUT_MSG_WIN 26 The Message window shortcut menu.
StatisticsWinShortcut M_SHORTCUT_STAT_WIN 27 The Statistics window shortcut menu.
AdornmentShortcut M_SHORTCUT_ADORNMENT 32 The Adornment window shortcut.
LcLayersShortcut M_SHORTCUT_LC_LAYERS 33 The Layer Control window shortcut that displays when right-clicking a regular layer in the layer list.
LcMapsShortcut M_SHORTCUT_LC_MAPS 34 The Layer Control window shortcut that displays when right-clicking a Map node in the layer list.
LcGroupsShortcut M_SHORTCUT_LC_GROUPS 35 The Layer Control window shortcut that displays when right-clicking a Group Layer in the layer list.
TableAdornmentShortcut M_SHORTCUT_TABLEADORNMENT 36 Reserved for future use.
TableListWindowShortcut M_SHORTCUT_TLV_TABLES 37 The Table List window shortcut that displays when right-clicking a table name.
OverridesShortcut M_SHORTCUT_LC_OVERRIDES 38 The Layer Control window shortcut that displays when right-clicking a Label Override or a Display Override.
BrowserFilterShortcut M_SHORTCUT_BROWSER_SORTFILTER 47 The Browser window shortcut that displays when clicking the Sort/Filter button.
BrowserSelectShortcut M_SHORTCUT_BROWSER_SELECT 48 The Browser window shortcut that displays when clicking the Selection button.
LegendDesignerShortcut M_SHORTCUT_LEGEND_DESIGNER 50 The Legend Designer window shortcut.

Table 3. ID Numbers for Non-Shortcut Menus
Menu Name Define ID Description
3DWindow M_3DMAP 28 3D Map window.
Graph M_GRAPHTDG 29 Graph menu.
Legend M_LEGEND 31 Legend menu.

When altering a Custom menu (even if you create it with an Custom ID, such as 999), you are required to use the Custom menuname, not the Custom ID, to alter it.

Examples

The following statement adds an item to the File menu.

Alter Menu "File" Add 
	"Special" Calling sub_procedure_name

In the following example, the menu to be modified is identified by its number.

Alter Menu ID 1 Add 
	"Special" Calling sub_procedure_name

In the following example, the menu item that is added contains an ID clause. The ID number (300) can be used in subsequent Alter Menu Item statements.

Alter Menu ID 1 Add 
	"Special" ID 300 Calling sub_procedure_name

The following example removes the custom item from the File menu.

Alter Menu ID 1 Remove sub_procedure_name

The sample program, TextBox, uses a Create Menu statement to create a menu called "TextBox," and then issues the following Alter Menu statement to add the TextBox menu as a hierarchical menu located on the Tools menu:

Alter Menu "Tools" Add 
	"(-", 
	"TextBox" As "TextBox" 

The following example adds a custom command to the Map window's shortcut menu (the menu that appears when an MapInfo Pro user right-clicks on a Map window).

Alter Menu ID 17 Add
	"Find Nearest Site" Calling sub_procedure_name

See Also:

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