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

Syntax

WindowInfo( window_spec, attribute ) 

window_spec is a number or a code that specifies which window you want to query.

attribute is an integer code indicating which information about the window to return.

Return Value

Depends on the attribute parameter.

Description

The WindowInfo() function returns one piece of information about an existing window.

Many of the values that you pass as the parameters to WindowInfo() are defined in the standard MapBasic definitions file, MAPBASIC.DEF. Your program should Include "MAPBASIC.DEF" if you are going to call WindowInfo().

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

Value of window_spec Description
Integer window ID You can use an integer window ID (which you can obtain by calling the WindowID() function or the FrontWindow() function) to specify which window you want to query.
Positive SmallInt value (1, 2, ... n ) The function queries a document window, such as a Map or Browser window. For example, specify 1 to retrieve information on 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) The function queries 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 WindowInfo() within a loop to query every open window.
Zero ( 0 ) The function queries the most recently-opened window. If no windows are open, an error occurs.
Window code (for example, WIN_RULER) If you specify a window code with a value from 1001 to 1013, the function queries a special system window. Window codes are defined in MAPBASIC.DEF. For example, MAPBASIC.DEF contains the code WIN_RULER (with a value of 1007), which represents the window used by MapInfo Pro's Ruler tool.

The attribute parameter dictates which window attribute the function should return. The attribute parameter must be one of the codes from the table below:

attribute code ID WindowInfo( attribute ) returns:
WIN_INFO_NAME 1 String value: the name of the window.
WIN_INFO_TYPE 3 SmallInt value: window type, such as WIN_LAYOUT (3). See table below.
WIN_INFO_WIDTH 4 Float value: window width (in paper units). For MapInfo Pro 64-bit, use the WIN_INFO_CLIENTWIDTH attribute. For details about paper units, see Set Paper Units statement.
WIN_INFO_HEIGHT 5 Float value: window height (in paper units). For MapInfo Pro 64-bit, use the WIN_INFO_CLIENTHEIGHT attribute.
WIN_INFO_X 6 Float value: the window's distance from the left edge of the MapInfo Pro work area (in paper units). If this window is embedded in a frame in a Layout Designer window, then this is the distance from the left edge of the Layout window. For MapInfo Pro 64-bit, returns most recent left position of floating window relative to left of primary screen.
WIN_INFO_Y 7 Float value: the window's distance from the top edge of the MapInfo Pro work area (in paper units). If this window is embedded in a frame in a Layout window, then this is the distance from the top edge of the Layout window. For MapInfo Pro 64-bit, returns most recent top position of floating window relative to top of primary screen
WIN_INFO_TOPMOST 8 Logical value: TRUE if this is the active window.
WIN_INFO_STATE 9 SmallInt value: These three state represent floating state in MapInfoPro 64 bit:
  • WIN_STATE_NORMAL if at normal size
  • WIN_STATE_MINIMIZED (1) if minimized
  • WIN_STATE_MAXIMIZED (2) if maximized
These are new states returned by windowinfo:
  • WIN_STATE_DOCKED (3) if docked
  • WIN_STATE_TABBED (4) if tabbed
  • WIN_STATE_AUTOHIDDEN (5) if auto-hidden
  • WIN_STATE_HIDDEN (6) if hidden
WIN_INFO_TABLE 10 String value: For Map windows, the name of the window's "CosmeticN" table. For classic Layout windows, the name of the window's "LayoutN" table. For Layout Designer windows it returns an empty string. For Browser or Graph windows, the name of the table displayed in the window.
WIN_INFO_ADORNMENTS_MAP 10 Overloaded with the same value as WIN_INFO_TABLE (10).

Integer value: If the WindowID is a Adornment, this returns the integer WindowID of the Map window used to create the Adornment.

WIN_INFO_LEGENDS_MAP 10 Overloaded with the same value as WIN_INFO_TABLE (10).

Integer value: If the WindowID is a Legend created using the Create Legend statement, this returns the integer window ID of the Map or Graph window that owns the legend. When you query the standard Legend window, returns 0.

WIN_INFO_OPEN 11 Logical value: TRUE if the window is open (used with special windows such as the Info window).
WIN_INFO_WND 12 IntPtr* value. On Windows, the value represents a Windows HWND for the window you are querying.
WIN_INFO_WINDOWID 13 Integer value, representing the window's ID; identical to the value returned by the WindowID() function. This is useful if you pass zero as the window_spec.
WIN_INFO_WORKSPACE 14 String value: the string of MapBasic statements that a Save Workspace operation would write to a workspace to record the settings for this map. Differs from WIN_INFO_CLONEWINDOW (15) in that the results include Open Table statement, etc.
WIN_INFO_CLONEWINDOW 15 String value: a string of MapBasic statements that can be used in a Run Command statement to duplicate a window.
WIN_INFO_SYSMENUCLOSE 16 Logical value: FALSE indicates that a Set Window statement has disabled the Close command on the window's system menu.
WIN_INFO_AUTOSCROLL 17 Logical value: TRUE if the autoscroll feature is on for this window, allowing the user to scroll the Map or Layout window by dragging to the window's edge. To turn autoscroll on or off, use the Set Window statement.
WIN_INFO_SMARTPAN 18 Logical value; TRUE if Smart Pan has been set on.
WIN_INFO_SNAPMODE 19 Returns a logical value. TRUE if snap mode is on. FALSE if snap mode is off.
WIN_INFO_SNAPTHRESHOLD 20 Returns a SmallInt value representing the pixel tolerance.
WIN_INFO_PRINTER_NAME 21 Returns string value with printer identifier (for example, \\DISCOVERY\HP4_DEVEL)
WIN_INFO_PRINTER_ORIENT 22 Returns WIN_PRINTER_PORTRAIT (1) or WIN_PRINTER_LANDSCAPE (2)
WIN_INFO_PRINTER_COPIES 23 Returns integer number of copies.
WIN_INFO_PRINTER_PAPERSIZE 24 Integer value. Refer to the PAPERSIZE.DEF file (In the \MapInfo\MapBasic directory) for the meaning of the return value.
WIN_INFO_PRINTER_LEFTMARGIN 25 Float value: left printer margin value in current units.
WIN_INFO_PRINTER_RIGHTMARGIN 26 Float value: right printer margin value in current units.
WIN_INFO_PRINTER_TOPMARGIN 27 Float value: top margin value in current units.
WIN_INFO_PRINTER_BOTTOMMARGIN 28 Float value: bottom printer margin value in current units.
WIN_INFO_PRINTER_BORDER (29) 29 String value: ON if a black border will be on the printer output, OFF otherwise.
WIN_INFO_PRINTER_TRUECOLOR 30 String value: ON if use 24-bit true color to print raster and grid images. This is possible when the image is 24 bit and the printer supports more than 256 colors, OFF otherwise.
WIN_INFO_PRINTER_DITHER 31 String value: return dithering method, which is used when it is necessary to convert a 24-bit image to 256 colors. Possible return values are HALFTONE and ERRORDIFFUSION. This option is used when printing raster and grid images. Dithering will occur if WIN_INFO_PRINTER_TRUECOLOR (30) is disabled or if the printer color depth is 256 colors or less.
WIN_INFO_PRINTER_METHOD 32 String value: possible return values are DEVICE, EMF, or PRINTOSBM.
WIN_INFO_PRINTER_TRANSPRASTER 33 String value: possible return values are DEVICE and INTERNAL.
WIN_INFO_PRINTER_TRANSPVECTOR 34 String value: possible return values are DEVICE and INTERNAL.
WIN_INFO_EXPORT_BORDER 35 String value: possible return values are ON and OFF.
WIN_INFO_EXPORT_TRUECOLOR 36 String value: possible return values are ON and OFF.
WIN_INFO_EXPORT_DITHER 37 String value: possible return values are HALFTONE and ERRORDIFFUSION.
WIN_INFO_EXPORT_TRANSPRASTER 38 String value: possible return values are DEVICE and ROP.
WIN_INFO_EXPORT_TRANSPVECTOR 39 String value: possible return values are DEVICE and INTERNAL.
WIN_INFO_PRINTER_SCALE_PATTERNS 40 Logical value. TRUE if window is scaled on printer output. FALSE if not scaled.
WIN_INFO_EXPORT_ANTIALIASING 41 String value: ON if a anti-aliasing filter will be used for exporting, OFF otherwise.
WIN_INFO_EXPORT_THRESHOLD 42 Integer value between 0 and 255 that specifies anti-aliasing threshold.
WIN_INFO_EXPORT_MASKSIZE 43 Integer value between 0 and 100
WIN_INFO_EXPORT_FILTER 44 Integer value that return one of possible anti-aliasing filters:
  • FILTER_VERTICALLY_AND_HORIZONTALLY (0)
  • FILTER_ALL_DIRECTIONS_1 (1)
  • FILTER_ALL_DIRECTIONS_2 (2)
  • FILTER_DIAGONALLY (3)
  • FILTER_HORIZONTALLY (4)
  • FILTER_VERTICALLY (5)
WIN_INFO_ENHANCED_RENDERING 45 Logical value: TRUE if enhanced rendering is on for this window. To turn enhanced rendering on or off, use the Set Window statement.
WIN_INFO_SMOOTH_TEXT 46 String value: The string representation of the current smooth text mode for the window. To change the smooth mode, use the Set Window statement.
WIN_INFO_SMOOTH_IMAGE 47 String value: The string representation of the current smooth image mode for the window. To change the smooth mode, use the Set Window statement.
WIN_INFO_SMOOTH_VECTOR 48 String value: The string representation of the current smooth vector mode for the window. To change the smooth mode, use the Set Window statement.
WIN_INFO_PARENT_LAYOUT 49 Integer value: Returns window id of parent layout window of an embedded window in layout; otherwise, returns 0.
WIN_INFO_CLIENTWIDTH 50 Integer value: Returns width of client window.
WIN_INFO_CLIENTHEIGHT 51 Integer value: Returns height of client window.
WIN_INFO_PRINTER_RESOLUTION 52 Integer value: Returns resolution of the printer.
WIN_INFO_TOPMOSTWHENFLOATING 53 Logical value: TRUE is window is topmost.

* IntPtr is a platform specific type that is used to represent a pointer or a handle. This helps to write applications that will work with both the 32-bit and 64-bit versions of MapInfo Pro. The 64-bit version of MapInfo Pro treats this like a LargeInt, and the 32-bit version of MapInfo Pro treats this like an Integer.

If you specify WIN_INFO_TYPE as the attribute, and WindowInfo() returns one of the following values. 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_CUSTOM 37 Custom window type (for example, MapInfo Marketplace - a WPF 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

Each Map window has a special, temporary table, which represents the "cosmetic layer" for that map. These tables (which have names like "Cosmetic1", "Cosmetic2", etc.) are invisible to the MapInfo Pro user. To obtain the name of a Cosmetic table, specify WIN_INFO_TABLE (10). Similarly, you can obtain the name of a Layout window's temporary table (for example, "Layout1") by calling WindowInfo() with the WIN_INFO_TABLE (10) attribute.

Enhanced rendering and smoothing options for Layout Designer windows

Attributes that return enhanced rendering and smoothing options are also applicable to Layout Designer windows. Use WindowInfo(win, attr) to set enhanced rendering settings for any Layout Designer window:

  • WIN_INFO_ENHANCED_RENDERING returns True if Enhanced rendering is On, False otherwise.
  • WIN_INFO_SMOOTH_IMAGE returns None, Low or High
  • WIN_INFO_SMOOTH_VECTOR returns None or Antialias
  • WIN_INFO_SMOOTH_TEXT will always return Antialias
Behavior for new Layout Windows

When creating a new Layout Window, the default enhanced rendering settings are:

  • Enhanced rendering: True
  • Image smoothing: High
  • Vector smoothing: Antialias
  • Text smoothing: always Antialias
You can then use Set Window statements to change these settings. When creating a new Layout Window, the default enhanced rendering settings are the same as those set in the Users' Preferences for Styles (except Text smoothing that will always be Antialias regardless of setting in Style Preferences).
Note: MapBasic control for smooth rendering of maps and legends is still controlled using the same Set Window Enhanced statement where the window_id applies to a map frame in a Layout Designer, or a stand-alone Mapper window. For this reason, Set Designer Legend Antialias On | Off is being deprecated.

Error Conditions

ERR_BAD_WINDOW (590) error is generated if the window_id parameter is invalid.

ERR_FCN_ARG_RANGE (644) error is generated if an argument is outside of the valid range.

Example

The following example opens the Statistics window if it isn't open already.

If Not WindowInfo(WIN_STATISTICS,WIN_INFO_OPEN) 
Then Open Window WIN_STATISTICS 
End If 

See Also:

WindowID() function, Browse statement, Map statement