IntersectRect

2.x

  BOOL IntersectRect(lprcDst, lprcSrc1, lprcSrc2)    
  RECT FAR* lprcDst; /* address of structure for intersection */
  const RECT FAR* lprcSrc1; /* address of structure with 1st rectangle */
  const RECT FAR* lprcSrc2; /* address of structure with 2nd rectangle */

The IntersectRect function calculates the intersection of two source rectangles and places the coordinates of the intersection rectangle into the destination rectangle. If the rectangles do not intersect, an empty rectangle (0, 0, 0, 0) is placed into the destination rectangle.

Parameters

lprcDst

Points to a RECT structure that receives the intersection of the rectangles pointed to by the lprcSrc1 and lprcSrc2 parameters. The RECT structure has the following form:

typedef struct tagRECT {    /* rc */
   int left;
   int top;
   int right;
   int bottom;
} RECT;

For a full description of this structure, see the Microsoft Windows Programmer's Reference, Volume 3.

lprcSrc1

Points to the RECT structure that contains the first source rectangle.

lprcSrc2

Points to the RECT structure that contains the second source rectangle.

Return Value

The return value is nonzero if the rectangles intersect. Otherwise, it is zero.

See Also

InflateRect, SubtractRect, UnionRect