Throughout DirectDraw and Windows programming, objects on the screen are referred to in terms of bounding rectangles. A bounding rectangle is described by two points, the top-left corner and bottom-right corner. Most applications use the RECT structure to carry information about a bounding rectangle to use when blitting to the screen or performing hit detection. The RECT structure has the following definition:
typedef struct tagRECT {
LONG left; // This is the top-left corner's X-coordinate.
LONG top; // The top-left corner's Y-coordinate.
LONG right; // The bottom-right corner's X-coordinate.
LONG bottom; // The bottom-right corner's Y-coordinate.
} RECT, *PRECT, NEAR *NPRECT, FAR *LPRECT;
In the preceding example, the left and top members are the X- and Y-coordinates of a bounding rectangle's top-left corner. Similarly, the right and bottom members make up the coordinates of the bottom-right corner. The following diagram illustrates how you can visualize these values: