TRegion provides a number of member functions to get information from the TRegion object, including whether a point is contained in or touches the region.
- You can use the TRegion::SetRectRgn function to reset the object's region to a rectangular region:
void SetRectRgn(
const TRect&
rect);
This function sets the TRegion's area to the logical coordinates contained in the TRect object passed as a parameter to SetRectRgn. The region is set to a rectangular region regardless of the shape that it previously had.
- You can use the TRegion::Contains function to find out whether a point is contained in a region:
bool Contains(
const TPoint&
point);
point contains the coordinates of the point in question. Contains returns true if point is within the region and false if not.
- You can use the TRegion::Touches function to find out whether any part of a rectangle is contained in a region:
bool Touches(
const TRect&
rect);
rect contains the coordinates of the rectangle in question. Touches returns true if any part of rect is within the region and false if not.
- You can use the TRegion::GetRgnBox functions to get the coordinates of the bounding rectangle of a region:
int GetRgnBox(TRect&
box);
TRect GetRgnBox();
The bounding rectangle is the smallest possible rectangle that encloses all the area contained in the region. The first version of this function takes a reference to a TRect object as a parameter. The function places the coordinates of the bounding rectangle in the TRect object. The return value indicates the complexity of the region, and can be one of the following: SIMPLEREGION (region has no overlapping borders), COMPLEXREGION (region has overlapping borders), or NULLREGION (region is empty). If the function fails, the return value is ERROR. The second version of GetRgnBox takes no parameters and returns a TRect that contains the coordinates of the bounding rectangle. The second version of this function does not indicate the complexity of the region.
See Also