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.
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