CommandInfo() function - 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

Returns information about recent events. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

CommandInfo( attribute )

attribute is an integer code indicating what type of information to return.

Return Value

Logical, float, integer, or string, depending on circumstances.

Description

The CommandInfo() function returns information about recent events that affect MapInfo Pro―for example, whether the "Selection" table has changed, where the user clicked with the mouse, or whether it was a simple click or a Shift+click.

After Displaying a Dialog Box

When you call CommandInfo() after displaying a custom dialog box, the attribute parameter can be one of these codes:

attribute code ID CommandInfo( attribute ) returns:
CMD_INFO_DLG_OK 1 Logical value: TRUE if the user dismissed a custom dialog box by clicking OK; FALSE if user canceled by clicking Cancel, pressing Esc. (This call is only valid following a Dialog statement.)
CMD_INFO_STATUS 1 Logical value: TRUE if the user allowed a progress-bar operation to complete, or FALSE if the user pressed the Cancel button to halt.

Within a Custom Menu or Dialog Handler

When you call CommandInfo() from within the handler procedure for a custom menu command or a custom dialog box, the attribute parameter can be one of these codes:

attribute code ID CommandInfo( attribute ) returns:
CMD_INFO_DLG_DBL 1 Logical value: TRUE if the user double-clicked on a ListBox or MultiListBox control within a custom dialog box. This call is only valid within the handler procedure of a custom dialog box.
CMD_INFO_MENUITEM 8 Integer value, representing the ID of the menu item the user chose. This call is only valid within the handler procedure of a custom menu item.

Ribbon Control

When you call CommandInfo() for a ribbon control, the attribute parameter can be one of these codes:

attribute code ID CommandInfo( attribute ) returns:
CMD_INFO_NAME 9 String value, returns the Name Property of the Control.
CMD_INFO_FULLNAME 10 String value, returns the full path to the Control in the Ribbon.

Within a Standard Handler Procedure

When you call CommandInfo() from within a standard system handler procedure (such as SelChangedHandler), the attribute parameter can be any of the codes from the following table. For details, see the separate discussions of SelChangedHandler, RemoteMsgHandler procedure, WinChangedHandler and WinClosedHandler. From within SelChangedHandler:

attribute code ID CommandInfo( attribute ) returns:
CMD_INFO_SELTYPE 1

1 if one row was added to the selection;

2 if one row was removed from the selection;

3 if multiple rows were added to the selection;

4 if multiple rows were de-selected.

CMD_INFO_ROWID 2 Integer value: The number of the row that was selected or de-selected (only applies if a single row was selected or de-selected).
CMD_INFO_INTERRUPT 3 Logical value: TRUE if the user interrupted a selection by pressing Esc, FALSE otherwise.

From within the RemoteMsgHandler procedure, the RemoteQueryHandler() function, or the RemoteMapGenHandler procedure:

attribute code ID CommandInfo( attribute ) returns:
CMD_INFO_MSG 1000 String value, representing the execute string or the item name sent to MapInfo Pro by a client program. For details, see RemoteMsgHandler procedure, RemoteQueryHandler() function, or RemoteMapGenHandler procedure.

From within WinChangedHandler procedure or WinClosedHandler procedure:

attribute code ID CommandInfo( attribute ) returns:
CMD_INFO_WIN 1 Integer value, representing the ID of the window that changed or the window that closed. For details, see WinChangedHandler procedure or WinClosedHandler procedure.

From within ForegroundTaskSwitchHandler procedure:

attribute code ID CommandInfo( attribute ) returns:
CMD_INFO_TASK_SWITCH 1 Integer value, indicating whether MapInfo Pro just became the active application or just stopped being the active application. The return value matches one of these codes: SWITCHING_INTO_MI Pro (If MapInfo Pro received the focus) SWITCHING_OUT_OF_MapInfo Pro (If MapInfo Pro lost the focus).

After a Find Operation

Following a Find statement, the attribute parameter can be one of these codes:

attribute code ID CommandInfo( attribute ) returns:
CMD_INFO_X or CMD_INFO_Y 1, 2 Floating-point number, indicating x- or y-coordinates of the location that was found.
CMD_INFO_FIND_RC 3 Integer value, indicating whether the Find statement found a match.
CMD_INFO_FIND_ROWID 4 Integer value, indicating the Row ID number of the row that was found.

Within a Custom ToolButton's Handler Procedure

Within a custom ToolHandler procedure, you can specify any of these codes:

attribute code ID CommandInfo( attribute ) returns:
CMD_INFO_CUSTOM_OBJ 1 Object value: a polyline or polygon drawn by the user. Applies to drawing modes DM_CUSTOM_POLYLINE or DM_CUSTOM_POLYGON.
CMD_INFO_X 1 x coordinate of the spot where the user clicked:
  • If the user clicked on a Map, the return value represents a map coordinate (e.g., longitude), in the current coordinate system unit.
  • If the user clicked on a Browser, the value represents the number of a column in the Browser (e.g., one for the left most column, or zero for the select-box column).*
  • If the user clicked in a Layout, the value represents the distance from the left edge of the Layout (e.g., zero represents the left edge), in MapBasic's current paper units. For details about paper units, see Set Paper Units statement.
CMD_INFO_Y 2 y-coordinate of the spot where the user clicked:
  • If the user clicked on a map, the value represents a map coordinate (e.g., Latitude).
  • If the user clicked on a Browser, the value represents a row number; a value of one represents the top row, and a value of zero represents the row of column headers at the top of the window.*
  • If the user clicked on a Layout, the value represents the distance from the top edge of the Layout.
CMD_INFO_SHIFT 3 Logical value: TRUE if the user held down the Shift key while clicking.
CMD_INFO_CTRL 4 Logical value: TRUE if the user held down the Ctrl key while clicking.
CMD_INFO_X2 5 x-coordinate of the spot where the user released the mouse button. This only applies if the toolbutton was defined with a draw mode that allows dragging, e.g., DM_CUSTOM_LINE.
CMD_INFO_Y2 6 y-coordinate of the spot where the user released the mouse button.
CMD_INFO_TOOLBTN 7 Integer value, representing the ID of the button the user clicked

* The CommandInfo() function ignores any clicks made in the top-left corner of a Browser window―above the select column and to the left of the column headers. It also ignores clicks made beyond the last column or row.

Hotlink Support

MapBasic applications launched via the Hotlink Tool can use the CommandInfo() function to obtain information about the object that was activated. The following is a table of the attributes that can be queried:

attribute code ID CommandInfo( attribute ) returns:
CMD_INFO_HL_WINDOW_ID 17 ID of map or browser window.
CMD_INFO_HL_TABLE_NAME 18 Name of table associated with the map layer or browser.
CMD_INFO_HL_ROWID 19 ID of the table row corresponding to the map object or browser row.
CMD_INFO_HL_LAYER_ID 20 Layer ID, if the program was launched from a map window.
CMD_INFO_HL_FILE_NAME 21 Name of file launched.

See Also:

FrontWindow() function, SelectionInfo() function, Set Command Info statement, WindowInfo() function