Set Window 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

Changes the size, position, title, or status of a window, and controls the printer, paper size, and margins used by MapInfo Pro. This statement has been updated and now you can use Enhanced rendering options to control smoothing of styles can for Layout Designer windows. This means that MapBasic statement that controls smoothing options for Map windows now applies to Layout Designer windows as well. You can issue this statement from the MapBasic window in MapInfo Pro.

Syntax

Set Window window_id 
	[ Position ( x, y ) [ Units paper_units ] ] 
	[ Width win_width [ Units paper_units ] ] 
	[ Height win_height [ Units paper_units ] ] 
	[ Font... ] 
	[ Enhanced { On | Off } ]
	[ Smooth [ Vector { None | Antialias } ] [ Text { None | Antialias } ] 
		[ Image { None | Low | High } ] ]
	[ Min | Max | Restore | Floating | Docked | Tabbed | AutoHidden ]
	[ Front ]
	[ Title { new_title | Default } ] 
	[ Help [ { File help_file | File Default | Off } [ Permanent ] ] 
		[ Contents ] [ ID context_ID ] { Show | Hide } ] 
	[ Printer { Default | Name printer_name }
		[ Orientation { Portrait | Landscape } ]
		[ Copies number ]
		[ Papersize number ]
		[ Border { On | Off } ]
		[ TrueColor { On | Off } ]
		[ Dither { Halftone | ErrorDiffusion } ]
		[ Method { Device | Emf | PrintOsbm } ]
		[ Transparency 
			[ Raster { Device | ROP } ]
			[ Vector { Device | Internal } ] ]
		[ Margins 
			[ Left d1 ] [ Right d2 ] [ Top d3 ] [ Bottom d4 ]
			[ Units paper_units ] ] ]
	[ Export { Default |
		[ Border { On | Off } ]
		[ TrueColor { On | Off } ]
		[ Dither { Halftone | ErrorDiffusion } ]
		[ Transparency 
			[ Raster { Device | ROP } ]
			[ Vector { Device | Internal } ] 
		] 
		[ Scale Patterns { On | Off } ]
		[ Antialiasing { On | Off } ] 
		[ Threshold threshold_value ]
		[ MaskSize size_value ]
		[ Filter filter_value ] } ]
	[ ScrollBars { On | Off } ] 
	[ Autoscroll { On | Off } ] 
	[ Parent HWND ] 
	[ ReadOnly | Default Access ] 
	[ Table table_name Rec record_number ] 
	[ Show | Hide ] 
	[ Smart Pan { On | Off } ]
	[ SysMenuClose { On | Off } ]
	[ Snap [ Mode { On | Off } ] ]
	[ Threshold { pixel_tolerance | Default } ]
	[ Toolbar { On | Off } ] 
	[ Topmost { On | Off } ]

window_id is an integer window identifier or a special window name (for example, Help).

x states the desired distance from the left of MapInfo Pro's workspace to the left edge of the window.

y states the desired distance from the top of MapInfo Pro's workspace to the top edge of the window.

paper_units is a string representing a paper unit name: cm (centimeters), mm (millimeters), in (inches), pt (points), and pica.

  • 1 inch (in) = 2.54 centimeters , 254 millimeters, 6 picas, 72 points
  • 1 point (pt) = 0.01389 inches, 0.03528 centimeters, 0.35278 millimeters, 0.08333 picas
  • 1pica = 0.16667 inches, 0.42333 centimeters, 4.23333 millimeters, 12 points
  • 1 centimeter (cm) = 0.39370 inches, 10 millimeters, 2.36220 picas, 28.34646 points
  • 1 millimeter (mm) = 0.1 centimeters, 0.03937 inches, 0.23622 picas, 2.83465 points

The Font clause specifies a text style.

win_width is the desired width of the window.

win_height is the desired height of the window.

new_title is a string expression representing a new title for the window.

help_file is the name of a help file (for example, "FILENAME.HLP" on Windows).

context_ID is an integer help file context ID which identifies a specific help topic.

printer_name identifies a printer. The printer can be local or networked to the computer on which MapInfo Pro is running.

number is the number of copies of a print job that should be sent to the printer.

HWND is an integer window handle. The window specified by HWND will become the parent of the window specified by window_id; however, only Legend, Statistics, Info, Ruler, and Message windows may be re-parented in this manner.

table_name is the name of an open table to use with the Info window.

record_number is an integer: specify 1 or larger to display a record in the Info window, or specify 0 to display a "No Record" message.

Enhanced sets the version of the rendering technology used to display and print graphics.

The On parameter enables the enhanced rendering technology and is set when the user selects the Enable Enhanced Rendering check box in the MapInfo Pro. The Off option disables the enhanced rendering technology and is set when the user does not select the Enable Enhanced Rendering check box in MapInfo Pro.

Smooth sets the new rendering technology enhancements for anti-aliasing vector, text and labels, and images.

Note: The Smooth options (Vector, Text, and Image) require that the Enhanced parameter be set to On. MapBasic will throw an error if you turn Enhanced Off and set any of the Smooth options to an option other than None.

Vector - sets the vector smoothing options for vectors.

None indicates that smoothing is turned off and the vector line and border objects are drawn without anti-aliasing.

Antialias indicates that smoothing is turned on and the vector objects. This option requires that the Enhanced parameter be set to On.

Text sets the text smoothing options for n-n-curved labels and the non-curved labels and text objects.

The None parameter indicates that smoothing is turned off for rotated and horizontal labels and text objects.

The Antialias parameter indicates that smoothing is turned on for rotated and horizontal labels and text objects. This option requires that the Enhanced parameter be set to On.

Image sets the raster image smoothing options.

None indicates that the smoothing is turned off for raster images.

Low indicates that the smoothing is turned on for raster images using a bilinear interpolation method. Using this method, the application displays better quality raster images than None but not as good as High. Using the Low option, the application displays raster images slower than when None is used but faster than when High is used. This option requires that the Enhanced parameter be set to On.

High indicates that the smoothing is turned on for raster images using a bicubic interpolation method. Using this method, the application displays better quality raster images than Low but results in slower display performance. This option requires that the Enhanced parameter be set to On.

Printer specifies window-specific overrides for printing.

Export specifies window-specific overrides for exporting.

Default will use the default values found in the output preferences corresponding to printing and/or exporting.

Name printer_name specifies the name of the printer to use.

Orientation Portrait prints the document using portrait orientation.

Orientation Landscape prints the document using landscape orientation.

Copies number specifies how many copies of the document to print.

Papersize number is the paper size information for the window. These numbers are universal for all printers under the Windows operating system. For example, 1 corresponds to Letter size, and 5 corresponds to Legal papersize. This number can be found in the MapBasic file, PAPERSIZE.DEF. Some printer drivers (for example big size plotters) can use their own numbering for identifying paper size. These numbers could be different from numbers that are provided in MapBasic definition file "PaperSize.def". Because of this, users with different printer drivers may not identify paper size information stored in a workspace correctly. In that case, paper size will be reset to the printer default value.

Border determines whether an additional black edged rectangle will be drawn around the extents of the window being printed or exported.

Truecolor determines whether to generate 24-bit true color output if it is possible to do so. If Truecolor is turned off, the output will be generated using 256 colors.

Dither determines which dithering method to use when it is necessary to convert a 24-bit image to 256 colors. This option is used when outputting raster and grid images. Dithering will occur if Truecolor is turned off or if the output device is not capable of supporting 24-bit color.

Method is a keyword that determines whether printing will go directly to the device driver or if MapInfo Pro will generate a Windows Enhanced Metafile first and then send that file to the printer. This method enables the printing of maps with raster images that may not have printed at all in earlier versions, and that use substantially smaller spool files.

Transparency Raster Internal has been removed; however, if present, the keyword will still be parsed without error to allow for compatibility with previous versions.

Transparency Raster determines how transparent pixels should be rendered. Select Device or ROP dependent upon your printer driver or export file format. You may need to determine your selection after trying each and determining which option produces the best output for you.

Transparency Raster ROP corresponds to the Use ROP Method to Display Transparent Raster option in the MapInfo Pro user interface (Output Preferences dialog box, and the Advanced button on the Print and Save Window As dialog boxes). If ROP is selected, the transparent image is rendered using a raster operation (ROP) to handle the transparent pixels. This method is used to draw transparent (non-translucent) images onscreen; however, it does not always work well when printing. You will need to experiment to determine if your printer driver handles ROP correctly. If you are exporting an image using the Save Window As command, this option is beneficial if the output format is a metafile (EMF or WMF). Using the ROP method allows any underlying data to be rendered in the original form.

Transparency Raster Device prevents MapInfo Pro from performing any special handling when printing raster or grid images that contain transparency. The image will be generated using the same method that is used to display the image(s) on screen, but there may be some problems with the output.

Transparency Vector Internal causes MapInfo Pro to perform special handling when outputting transparent fill patterns or transparent bitmap symbols.

Transparency Vector Device prevents MapInfo Pro performing special handling when outputting transparent fill patterns or transparent bitmap symbols. This may cause problems with the output.

Margins User can set printer margins as floating point values in desired units. These values may be increased by the printer driver if the printer margins are smaller than physically possible on a particular printer.

Antialiasing determines whether anti-aliasing filter is used during image exporting. Antialiasing is ignored when images are exported to EMF or WMF formats, and when exporting the contents of a Browser window.

Threshold specifies a value that indicates which pixels to smooth. The application of the ant-aliasing filter on the image associates a value with each pixel. Only pixels with values above threshold_value are smoothed. If threshold_value is set to zero, than all pixels are smoothed. threshold_value should be in the range from 0 to 255.

MaskSize specifies a value that indicates the size of the anti-aliasing mask. For example, a value of three indicates an anti-aliasing mask of 3x3. If user sets mask size_value too high, then the resulting image can become too blurry.

Filter specifies which anti-aliasing filter to apply. Currently MapInfo Pro supports 6 different filters as listed in the table below.

Filter ID Description
FILTER_VERTICALLY_AND_HORIZONTALLY 0 Anti-alias image vertically and horizontally.
FILTER_ALL_DIRECTIONS_1 1 Anti-alias image in all directions
FILTER_ALL_DIRECTIONS_2 2 Anti-alias image in all directions. The filter used for this option is different than FILTER_ALL_DIRECTIONS_1 and gets better results for anti-aliasing text.
FILTER_DIAGONALLY 3 Anti-alias image diagonally.
FILTER_HORIZONTALLY 4 Anti-alias image horizontally
FILTER_VERTICALLY 5 Anti-alias image vertically

Toolbar shows or hides the toolbar at the top of the window. This applies only to Browser windows. For example:

Set Window windowId Toolbar Off 

Topmost sets the explorer window as the topmost window.

Description

The Set Window statement customizes an open window, setting such options as the window's size, position, status, font, or title.

You can also use this statement to hide the toolbar at the top of the Legend window.

The window_id parameter can be an integer window identifier, which you can obtain by calling the FrontWindow() function and the WindowInfo() function. Alternately, when you use the Set Window statement to affect a special MapInfo Pro window, such as the Statistics window, you can identify the window by its name (for example, Statistics) or by its code (for example, WIN_STATISTICS); codes are defined in MAPBASIC.DEF.

The table below lists the window names and window codes which you can use as the window_id parameter. 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.

value Window Description
Help The Help window (WIN_HELP).
Info The Info Tool window (WIN_INFO).
Legend The Theme Legend window (WIN_LEGEND).
MapBasic The MapBasic window (WIN_MAPBASIC).
Message The Message window used by the Print statement (WIN_MESSAGE).
Ruler The Ruler tool window (WIN_RULER).
Statistics The Statistics window (WIN_STATISTICS).

The optional Position clause controls the window's position in the MapInfo Pro workspace. The upper left corner of the workspace has the position 0, 0. The optional Width and Height clauses control the window's size. Window position and size values use paper units settings, such as "in" (inches) or "cm" (centimeters). MapBasic has a current paper units setting, which defaults to inches; a MapBasic program can change this setting through the Set Paper Units statement. A Set Window statement can override the current paper units by including the optional Units subclause within the Position, Width, and Height clauses.

If the statement includes the optional Max keyword, the window will be maximized (it will occupy all of MapInfo Pro's work space). If the statement includes the optional Min keyword, the window will be minimized (it will be reduced, appearing only as a small icon in the lower part of the screen). If a window is already minimized or maximized, and if the statement includes the optional Restore keyword, the window is restored to its previous size. You can also add the following optional states:

  • Floating docking state makes the window floating.
  • Docked docking state docks the window to the default position.
  • Tabbed docking stae makes the window tabbed, in this state it is also called as a document.
  • AutoHidden docking state auto hides the window.
Note: All four docking states above are specific only to the 64-bit version of MapInfo Pro.

If the statement includes the optional Front keyword, MapBasic makes the window the active window; this is also known as setting the focus on the window. The window comes to the front, as if the user had clicked on the window's title bar. If window_id is an embedded map frame in a Layout window, then the frame activates. You may only have one active frame, even if it is in a different layout, or window.

The statement may always specify a Position clause or a Front clause, regardless of the type of window specified. However, some of the clauses in the Set Window statement apply only to certain types of windows. For example, the Ruler Tool window may not be re-sized, maximized or minimized.

To change the window's title, include the optional Title clause. The Application window title (the main "MapInfo" title bar) cannot be changed unless the user is running a runtime version of MapInfo Pro.

The Show and Hide clauses apply to document windows, such as Map, Browser, Redistricter, Layout, 3D Graph, Legend windows. The following illustrates how to show or hide a window. The id is the window identifier.

Set Window id Show
Set Window id Hide

The Show and Hide clauses also apply to tool windows, such the Connection List, Task Manager, Tool manager, Window List, and Workspace Explorer windows. The following illustrates how to show or hide a Connection List tool window:

Set Window connectionlist Show
Set Window connectionlist Hide

Use connectionlist, taskmanager, toolmanager, windowlist, or workspaceexplorer to show or hide a tool window.

For document windows where the window id is known, the show/hide state can be determined by executing the following where id is the window identifier:

print WindowInfo(id, WIN_INFO_OPEN)

For the tool windows, instead of WIN_INFO_OPEN use one of the following to determine the window id.

Window Type ID Window Description
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

The Method clause determines whether printing will go directly to the device driver or if MapInfo Pro will generate a Windows Enhanced Metafile first and then send the file to the printer or MapInfo will use an Offscreen bitmap to create the output first. EMF method enables the printing of maps with raster images that may not have printed at all in earlier versions, and that use substantially smaller spool files. Offscreen bitmap is invoked depending upon the type of translucent content in the map and enhanced rendering state of the window. However setting OSBM from this window means that printing will use Offscreen bitmaps regardless of the translucency and anti alias settings.

The SysMenuClose clause lets you disable the Close command in the window's system menu (the menu that appears when a user clicks the box in the upper-left corner of a window). Disabling the Close command only affects the user interface; MapBasic programs can still close the window by issuing Close Window statement. The following example disables the Close command of the active window:

Set Window FrontWindow() SysMenuClose Off
Note: Before version 10.5, you could enable or disable the Close button regardless of the toolbar's floating or docking state. As of version 10.5, you cannot enable or disable the Close button when the toolbar is docked. You can only change the state when it is floating or floating and hidden.

Enhanced rendering options for Layout Designer windows

Enhanced rendering options to control smoothing of styles can for Layout Designer windows. This means that MapBasic statement that controls smoothing options for Map windows now applies to Layout Designer windows as well.

Set Window layout_window_id [ Enhanced { On | Off } [ Smooth [ Vector { None | Antialias } ] [ Image { None | Low | High } ] ]

To apply Smooth options for a Layout Designer, make sure enhanced rendering is on, for example:

Set Window layout_window_id Enhanced On

When Enhanced is Off, no smoothing is applied. The Vector sub-clause can be used to toggle smooth rendering for line styles, and the Image sub-clause can be used to toggle smoothing for custom symbols and image frames in the Layout. You can also combine smoothing options in one statement:

Set Window layout_window_id Enhanced On Smooth Vector Antialias Image High
Vector sub-clause

Use the Vector sub-clause to toggle smoothing for line styles on frame borders, shape outlines or shape lines or polylines. For example, when Enhanced is on, Set Window layout_window_id Smooth Vector Antialias will smooth line styles for all frame borders and shapes on every page of the Layout window identified by layout_window_id, where as Set Window layout_window_id Smooth Vector None will draw all line styles without anti-aliasing.

Image sub-clause

Use the Image sub-clause to toggle smoothing for custom symbols and image frames. For example, when Enhanced is on,

Set Window layout_window_id Smooth Image High will render all images in image frames and custom symbols using the highest quality smoothing, where as Set Window layout_window_id Smooth Image None will turn off smoothing for all images in image frames and custom symbols in the Layout window.

Text sub-clause

There is a clause to control smoothing for Map window text: [ Text { None | Antialias } ], however it does not apply to Layout Designers. All text in the Layout Designer is always drawn anti-aliased.