Udostępnij za pośrednictwem


CRect::UnionRect

Makes the dimensions of CRect equal to the union of the two source rectangles.

BOOL UnionRect( 
   LPCRECT lpRect1, 
   LPCRECT lpRect2  
) throw( );

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.

Return Value

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

Remarks

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);   

Requirements

Header: atltypes.h

See Also

Reference

CRect Class

Hierarchy Chart

CRect::operator |=

CRect::operator |

CRect::IntersectRect

CRect::SubtractRect

CRect::NormalizeRect

UnionRect

Other Resources

CRect Members