WinChangedHandler procedure - 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

A reserved procedure, called automatically when a Map window is panned or zoomed, or whenever a map layer is added or removed.

Syntax

Declare Sub WinChangedHandler 
Sub WinChangedHandler 
	 statement_list 
End Sub 

statement_list is a list of statements to execute when the map is panned or zoomed.

Description

WinChangedHandler is a special-purpose MapBasic procedure name. If the user runs an application containing a procedure named WinChangedHandler, the application "goes to sleep" when the Main procedure runs out of statements to execute. As long as the sleeping application remains in memory, MapBasic calls WinChangedHandler whenever a Map window's extents are modified (for example, the Map is scrolled, zoomed or re-sized). Within the WinChangedHandler procedure, call the CommandInfo() function to determine the integer window ID of the affected window.

Multiple MapBasic applications can be "sleeping" at the same time. When a Map window changes, MapBasic automatically calls all sleeping WinChangedHandler procedures, one after another.

Under some circumstances, MapBasic may call a WinChangedHandler procedure as a result of an event which did not affect the map extents. For example, drawing a new object may trigger the WinChangedHandler procedure. To halt a sleeping application and remove it from memory, use the End Program statement.

Auto-scrolling Map Windows

MapInfo Pro automatically scrolls the Map window if the user clicks with the mouse and then drags to the edge of the window. If the user auto-scrolls a Map window, MapInfo Pro calls WinChangedHandler after the tool action is completed or canceled.

For example, if you use MapInfo Pro's Ruler tool and you autoscroll the window during each segment, MapInfo Pro calls WinChangedHandler once, after you double-click to complete the measurement (or after you press Esc to cancel the Ruler tool). If the user auto-scrolls while using a custom MapBasic tool, MapInfo Pro calls the tool's handler procedure, and then calls WinChangedHandler.

MapInfo Pro will not call WinChangedHandler if the user auto-scrolls but then returns to the original location before completing the operation or pressing Esc.

To disable the autoscroll feature, use the Set Window statement.

Example

For an example of using a WinChangedHandler procedure, see the OverView sample program.

See Also:

CommandInfo() function, WinClosedHandler procedure