Export (0) Print
Expand All

IntersectRect function

The IntersectRect function calculates the intersection of two source rectangles and places the coordinates of the intersection rectangle into the destination rectangle. If the source rectangles do not intersect, an empty rectangle (in which all coordinates are set to zero) is placed into the destination rectangle.

Syntax


BOOL IntersectRect(
  _Out_  LPRECT lprcDst,
  _In_   const RECT *lprcSrc1,
  _In_   const RECT *lprcSrc2
);

Parameters

lprcDst [out]

A pointer to the RECT structure that is to receive the intersection of the rectangles pointed to by the lprcSrc1 and lprcSrc2 parameters. This parameter cannot be NULL.

lprcSrc1 [in]

A pointer to the RECT structure that contains the first source rectangle.

lprcSrc2 [in]

A pointer to the RECT structure that contains the second source rectangle.

Return value

If the rectangles intersect, the return value is nonzero.

If the rectangles do not intersect, the return value is zero.

Remarks

Because applications can use rectangles for different purposes, the rectangle functions do not use an explicit unit of measure. Instead, all rectangle coordinates and dimensions are given in signed, logical values. The mapping mode and the function in which the rectangle is used determine the units of measure.

Examples

For an example, see Using Rectangles.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

Rectangles Overview
Rectangle Functions
InflateRect
OffsetRect
RECT
UnionRect

 

 

Community Additions

ADD
Show:
© 2014 Microsoft