Rectangles

Windows CE uses rectangles to specify clipping regions, identify portions of the client area that need to be repainted, and define areas for displaying text and graphics among other things. You use a RECT structure to define a rectangle. The structure specifies the coordinates of two points: the upper-left and lower-right corners of the rectangle. The sides of the rectangle extend from these two points and are parallel to the x-axis and the y-axis.

Because applications can use rectangles for many different purposes, the Windows rectangle functions do not use an explicit unit of measure. Instead, all rectangle coordinates and dimensions are conveyed in signed, logical values. The function in which the rectangle is used determines the unit of measure.

The SetRect function creates a rectangle, the CopyRect function makes a copy of a specified rectangle, and the SetRectEmpty function creates an empty rectangle. An empty rectangle is any rectangle that has zero width, zero height, or both. The IsRectEmpty function determines whether a specified rectangle is empty. The EqualRect function determines whether two rectangles are identical — that is, whether they have the same coordinates.

The InflateRect function increases or decreases the width or height of a rectangle or both. The OffsetRect function moves a rectangle by a specified amount. The PtInRect function determines whether a specified point lies within a specified rectangle. The point is in the rectangle if it lies on the left or top edge of the rectangle or is completely within the rectangle. The point is not in the rectangle if it lies on the right or bottom edge. The IntersectRect function creates a new rectangle that is the intersection of two existing rectangles. The UnionRect function creates a new rectangle that is the union of two existing rectangles.