WinClosedHandler 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, Browse, Graph, Layout, Redistricting, Legend, MapBasic window is closed.

Syntax

Declare Sub WinClosedHandler
Sub WinClosedHandler 
	 statement_list 
End Sub 

statement_list is a list of statements to execute when a window is closed.

Description

WinClosedHandler is a special-purpose MapBasic sub procedure name. If the user runs an application containing a procedure named WinClosedHandler, 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 automatically calls the WinClosedHandler procedure whenever a window is closed.

Within the WinClosedHandler procedure, you can use issue the function call:

CommandInfo( CMD_INFO_WIN )

to determine the window identifier of the closed window.

Note: When any procedure in an application executes the End Program statement, the application is completely removed from memory. Thus, you can use the End Program statement to terminate a WinClosedHandler procedure once it is no longer wanted. Conversely, you should be careful not to issue an End Program statement while the WinClosedHandler procedure is still needed.

Multiple MapBasic applications can be "sleeping" at the same time. When a window is closed, MapBasic automatically calls all sleeping WinClosedHandler procedures, one after another.

See Also:

CommandInfo() function, EndHandler procedure, RemoteMsgHandler procedure, SelChangedHandler procedure, ToolHandler procedure, WinChangedHandler procedure