Purpose
A reserved procedure, called automatically when the set of selected rows changes.
Syntax
Declare Sub SelChangedHandler
Sub SelChangedHandler
statement_list
End Sub
statement_list is a list of statements to execute when the set of selected rows changes.
Description
SelChangedHandler is a special MapBasic procedure name. If the user runs an application with a procedure named SelChangedHandler, the application "goes to sleep" when the Main procedure runs out of statements to execute. The sleeping application remains in memory until the application executes an End Program statement. As long as the application remains in memory, MapInfo Pro automatically calls the SelChangedHandler procedure whenever the set of selected rows changes.
Within the SelChangedHandler procedure, you can obtain information about recent changes made to the selection by calling CommandInfo() function with one of the following codes:
attribute code | ID | CommandInfo( attribute ) returns: |
---|---|---|
CMD_INFO_SELTYPE | 1 | 1 if one row was added to the selection; 2 if one row was removed from the selection; 3 if multiple rows were added to the selection; 4 if multiple rows were de-selected. |
CMD_INFO_ROWID | 2 | Integer value: The number of the row which was selected or de-selected (only applies if a single row was selected or de-selected). |
CMD_INFO_INTERRUPT | 3 | Logical value: TRUE if the user interrupted a selection process by pressing Esc; FALSE otherwise. |
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 SelChangedHandler procedure once it is no longer wanted. Be careful not to issue an End Program statement while the SelChangedHandler procedure is still needed.
Multiple MapBasic applications can be "sleeping" at the same time. When the Selection table changes, MapBasic automatically calls all sleeping SelChangedHandler procedures, one after another.
A SelChangedHandler procedure should not take actions that affect the GUI "focus" or reset the current window. In other words, the SelChangedHandler procedure should not issue statements such as a Note statement, Print statement, or Dialog statement.
See Also:
CommandInfo() function, SelectionInfo() function