1.18.3 Creating and Manipulating Rectangles

The SetRect function creates a rectangle, the CopyRect function makes a copy of a given rectangle, and the SetRectEmpty function creates an empty rectangle. An empty rectangle is any rectangle that has zero width, zero height, or both.

The InflateRect function increases or decreases the width or height of a rectangle, or both. It can add or remove width from both ends of the rectangle; it can add or remove height from both the top and bottom of the rectangle.

The OffsetRect function moves the rectangle by a given amount. It moves the rectangle by adding the given x-amount, y-amount, or x- and y-amounts to the corner coordinates.

The PtInRect function finds out whether a given point lies within a given rectangle. The point is in the rectangle if it lies on the left or top side or is completely within the rectangle.

The IsRectEmpty function finds out whether the given rectangle is empty.

The IntersectRect function creates a new rectangle that is the intersection of
two existing rectangles. The intersection is the largest rectangle contained in
both existing rectangles. The intersection of two rectangles can be illustrated
as follows.

The UnionRect function creates a new rectangle that is the union of two existing rectangles. The union is the smallest rectangle that contains both existing rectangles. The union of two rectangles can be illustrated as follows.

For information about functions that draw ellipses and polygons, see Chapter 2, “Graphics Device Interface.”