CRect::IntersectRect
Makes a CRect equal to the intersection of two existing rectangles.
BOOL IntersectRect(
LPCRECT lpRect1,
LPCRECT lpRect2
) throw( );
Параметры
lpRect1
Points to a RECT structure or CRect object that contains a source rectangle.lpRect2
Points to a RECT structure or CRect object that contains a source rectangle.
Возвращаемое значение
Nonzero if the intersection is not empty; 0 if the intersection is empty.
Заметки
The intersection is the largest rectangle contained in both existing rectangles.
![]() |
---|
Both of the rectangles must be normalized or this function may fail. You can call NormalizeRect to normalize the rectangles before calling this function. |
Пример
CRect rectOne(125, 0, 150, 200);
CRect rectTwo(0, 75, 350, 95);
CRect rectInter;
rectInter.IntersectRect(rectOne, rectTwo);
// rectInter is now (125, 75, 150, 95)
ASSERT(rectInter == CRect(125, 75, 150, 95));
// operator &= can do the same task:
CRect rectInter2 = rectOne;
rectInter2 &= rectTwo;
ASSERT(rectInter2 == CRect(125, 75, 150, 95));
Требования
Header: atltypes.h