Share via


CRect::UnionRect

BOOLUnionRect(LPCRECTlpRect1**,LPCRECTlpRect2);**

Return Value

Nonzero if the union is not empty; 0 if the union is empty.

Parameters

lpRect1

Points to a RECT or CRect that contains a source rectangle.

lpRect2

Points to a RECT or CRect that contains a source rectangle.

Remarks

Makes the dimensions of CRect equal to the union of the two source rectangles. The union is the smallest rectangle that contains both source rectangles.

Windows ignores the dimensions of an empty rectangle; that is, a rectangle that has no height or has no width.

Note   Both of the rectangles must be normalized or this function may fail. You can call NormalizeRect to normalize the rectangles before calling this function.

Example

CRect   rect1(100,   0, 200, 300);
CRect   rect2(  0, 100, 300, 200);
CRect   rect3;

rect3.UnionRect(&rect1, &rect2);

CRect   rectResult(0, 0, 300, 300);
ASSERT(rectResult == rect3);

CRect OverviewClass MembersHierarchy Chart

See Also   CRect::operator |=, CRect::operator |, CRect::IntersectRect, CRect::SubtractRect, CRect::NormalizeRect,