Purpose
A reserved procedure name, called automatically when the window focus changes.
Syntax
Declare Sub WinFocusChangedHandler
Sub WinFocusChangedHandler
statement_list
End Sub
Description
If a MapBasic application contains a sub procedure called WinFocusChangedHandler, MapInfo Pro calls the sub procedure automatically, whenever the window focus changes. This behavior applies to all MapInfo Pro window types (Map, Browse, Graph, Layout, Redistricting, Legend, or MapBasic window). Within the WinFocusChangedHandler procedure, you can obtain the integer window ID of the current window by calling CommandInfo(CMD_INFO_WIN).
The WinFocusChangedHandler procedure should not use the Note statement and should not open or close any windows. These restrictions are similar to those for other handlers, such as the SelChangedHandler procedure.
The WinFocusChangedHandler procedure should be as short as possible, to avoid slowing system performance.
Example
The following example shows how to enable or disable a menu item, depending on whether the active window is a Map window.
Include "mapbasic.def"
Include "menu.def"
Declare Sub Main
Declare sub WinFocusChangedHandler
Sub Main
' At this point, we could create a custom menu item
' which should only be enabled if the current window
' is a Map window...
End Sub
Sub WinFocusChangedHandler
Dim i_win_type As SmallInt
i_win_type=WindowInfo(CommandInfo(CMD_INFO_WIN),WIN_INFO_TYPE)
If i_win_type = WIN_MAPPER Then
' here, we could enable a map-related menu item
Else
' here, we could disable a map-related menu item
End If
End Sub
See Also:
WinChangedHandler procedure