CRect( );
CRect( int l, int t, int r, int b );
CRect( const RECT& srcRect );
CRect( LPCRECT lpSrcRect );
CRect( POINT point, SIZE size );
CRect( POINT topLeft, POINT bottomRight );
Parameters
l
Specifies the left position of CRect.
t
Specifies the top of CRect.
r
Specifies the right position of CRect.
b
Specifies the bottom of CRect.
srcRect
Refers to the RECT structure with the coordinates for CRect.
lpSrcRect
Points to the RECT structure with the coordinates for CRect.
point
Specifies the origin point for the rectangle to be constructed. Corresponds to the top-left corner.
size
Specifies the displacement from the top-left corner to the bottom-right corner of the rectangle to be constructed.
topLeft
Specifies the top-left position of CRect.
bottomRight
Specifies the bottom-right position of CRect.
Remarks
Constructs a CRect object. If no arguments are given, left, top, right, and bottom members are not initialized.
The CRect( const RECT& ) and CRect( LPCRECT ) constructors perform a CopyRect. The other constructors initialize the member variables of the object directly.
Example
// default constructor doesn't initialize!
CRect rectUnknown;
// four-integers are left, top, right, and bottom
CRect rect(0, 0, 100, 50);
ASSERT(rect.Width() == 100);
ASSERT(rect.Height() == 50);
// Initialize from RECT stucture
RECT sdkRect;
sdkRect.left = 0;
sdkRect.top = 0;
sdkRect.right = 100;
sdkRect.bottom = 50;
CRect rect2(sdkRect); // by reference
CRect rect3(&sdkRect); // by address
ASSERT(rect2 == rect);
ASSERT(rect3 == rect);
// from a point and a size
CPoint pt(0, 0);
CSize sz(100, 50);
CRect rect4(pt, sz);
ASSERT(rect4 == rect2);
// from two points
CSize szTopLeft(0, 0);
CRect rect5(szTopLeft, sz);
ASSERT(rect5 == rect4);
CRect Overview | Class Members | Hierarchy Chart
See Also CRect::SetRect, CRect::CopyRect, CRect::operator =, CRect::SetRectEmpty