SearchRect() function - 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

Searches for map objects within a rectangular area. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

SearchRect( map_window_id, x1, y1, x2, y2 ) 

map_window_id is a Map window's integer ID number.

x1, y1 are coordinates that specify one corner of a rectangle.

x2, y2 are coordinates that specify the opposite corner of a rectangle.

Return Value

Integer, representing the number of objects found.

Description

The SearchRect() function searches for map objects within a rectangular area. The search applies to all selectable layers in the Map window, even the Cosmetic layer (if it is currently selectable). The return value indicates the number of objects found.

Note: This function does not select any objects, nor does it affect the current selection. Instead, this function builds a list of objects in memory. After calling SearchRect() you call SearchInfo() function to process the search results.

The search behavior matches the behavior of MapInfo Pro's Marquee Select button: If an object's centroid falls within the rectangle, the object is included in the search results.

To allow the user to select a rectangular area with the mouse, use the Create ButtonPad statementor the Alter Button statement to create a custom ToolButton. Use DM_CUSTOM_RECT as the button's draw mode. Within the button's handler procedure, call CommandInfo() function to determine the x/y coordinates.

Example

For a code example, see the SearchInfo() function.

See Also:

SearchInfo() function, SearchPoint() function