Udostępnij za pośrednictwem


CRect::NormalizeRect

Normalizes CRect so that both the height and width are positive.

void NormalizeRect( ) throw( );

Remarks

The rectangle is normalized for fourth-quadrant positioning, which Windows typically uses for coordinates. NormalizeRect compares the top and bottom values, and swaps them if the top is greater than the bottom. Similarly, it swaps the left and right values if the left is greater than the right. This function is useful when dealing with different mapping modes and inverted rectangles.

Note

The following CRect member functions require normalized rectangles in order to work properly: Height, Width, Size, IsRectEmpty, PtInRect, EqualRect, UnionRect, IntersectRect, SubtractRect, operator ==, operator !=, operator |, operator |=, operator &, and operator &=.

Example

CRect rect1(110, 100, 250, 310);
CRect rect2(250, 310, 110, 100);

rect1.NormalizeRect();
rect2.NormalizeRect();

// rect1 should be unchanged
// rect2 becomes (110, 100, 250, 310)

ASSERT(rect1 == rect2);   

Requirements

Header: atltypes.h

See Also

Reference

CRect Class

Hierarchy Chart

Other Resources

CRect Members