WindowID() 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 a MapInfo Pro window identifier. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

WindowID( window_num ) 

window_num is a number or a numeric code; see table below.

Return Value

Integer

Description

A window identifier is an integer value which uniquely identifies an existing window. Several MapBasic statements (for example, the Set Map statement) take window identifiers as parameters.

The following table lists the various ways that you can specify the window_num parameter:

Value of window_num Result
Positive SmallInt value (1, 2, ... n ) MapInfo Pro returns the window ID of a document window, such as a Map or Browse window. For example, if you specify 1, MapInfo Pro returns the integer ID of the first document window. Note that n is the number of open document windows; call the NumWindows() function to determine n.
Negative SmallInt value (-1,-2, ...-m) MapInfo Pro returns the window ID of a window, which may be a document window or a floating window such as the Info window. Note that m is the total number of windows owned by MapInfo Pro; call the NumAllWindows() function to determine m. Using this syntax, you could call WindowID() within a loop to build a list of the ID numbers of all open windows.
Zero ( 0 ) MapInfo Pro returns the window ID of the most recently opened document window, custom Legend window, or ButtonPad; returns zero if no windows are open.
Note: In MapInfo RunTime, if only a Map window is open, there is also a hidden Explorer window with it. This may cause WindowID(0) to return 0. If the Explorer window is open and visible, WindowID(0) should return the Mapper window ID.
Window code (for example, WIN_RULER) If you specify a window code with a value from 1001 to 1013, MapInfo Pro returns the ID of a special window. Window codes are defined in MAPBASIC.DEF. For example, the code WIN_RULER (with a value of 1007) represents the window used by MapInfo Pro's Ruler tool.

The following are the window codes that this function returns. Window IDs for Table List (WIN_TABLE_LIST, 2001), Layer Control (WIN_LAYER_CONTROL, 2002), and Move Map To (WIN_MOVE_MAP_TO 2003) windows are ignored.

Window type ID Window description
WIN_MAPPER 1 Map window
WIN_BROWSER 2 Browse window
WIN_LAYOUT 3 Layout window
WIN_GRAPH 4 Graph window
WIN_BUTTONPAD 19 A ButtonPad window
WIN_TOOLBAR 25 The Toolbar window
WIN_CART_LEGEND 27 The Cartographic Legend window
WIN_3DMAP 28 The 3D Map window
WIN_ADORNMENT 32 The Adornment window
WIN_LEGEND_DESIGNER 35 The Legend window
WIN_LAYOUT_DESIGNER 36 The Layout Window
WIN_HELP 1001 The Help window
WIN_MAPBASIC 1002 The MapBasic window
WIN_MESSAGE 1003 The Message window (used with the Print statement)
WIN_RULER 1007 The Ruler window (displays the distances measured by the Ruler tool)
WIN_INFO 1008 The Info window (displays data when the user clicks with the Info tool)
WIN_LEGEND 1009 The Theme Legend window
WIN_STATISTICS 1010 The Statistics window
WIN_MAPINFO 1011 The MapInfo Pro application window
WIN_WORKSPACE_EXPLORER 2004 The Workspace Explorer window
WIN_WINDOW_LIST 2005 The Window List window
WIN_TOOL_MANAGER 2006 The Tool Manager window
WIN_TASK_MANAGER 2007 The Task Manager window
WIN_CONNECTION_LIST 2008 The Connection List window
WIN_NOTIFICATIONS 2009 Notifications are used by MapInfo Pro or add-ins to tell that something needs attention. You can see notifications in the Notifications Window.
WIN_QUERY_BUILDER 2010 Improved SQL Select dialog

Error Conditions

ERR_BAD_WINDOW_NUM (648) error is generated if the window_num parameter is invalid.

See Also:

WindowInfo() function, FrontWindow() function, NumWindows() function