
TRegion provides a number of member functions to get information from
Member functions
the TRegion object, including whether a point is contained in or touches the
region:
■ Y u can use the SetRectRgn function to reset the object’ region to ao s
rectangular region:
void SetRectRgn(const TRect& rect);
This sets the TRegion’ area to the logical coordinates contained in thes
TRect object passed as a parameter to the SetRectRgn function. The region
is set to a rectangular region regardless of the shape that it previously
had.
■ Y u can use the Contains function to find out whether a point iso
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.
■ Y u can use the T uches function to find out whether any part of ao o
rectangle is contained in a region:
BOOL Touches(const TRect& rect);
rect contains the coordinates of the rectangle in question. T uches returnso
TRUE if any part of rect is within the region and FALSE if not.
■ Y u can use the GetRgnBox functions to get the coordinates of theo
bounding rectangle of a region:
int GetRgnBox(TRect& box);
TRect GetRgnBox();
The bounding rectangle is the smallest possible rectangle that encloses all
of 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 either
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, which contains the coordinates of the bounding rectangle. The
second version of this function doesn’t indicate the complexity of the
region.
Chapter 13, Graphics objects
313