CRect

Win32++

CRect Class

Description

A CRect can be used anywhere that a RECT structure could be used.

CRect Members

CRect
CRect();
CRect(int Left, int Top, int Right, int Bottom);
CRect(const RECT& rc);
CRect(POINT pt, SIZE sz);
CRect(POINT topLeft, POINT bottomRight);
Constructs the CRect.
operator =
void operator=(const RECT& srcRect);
Assigns a RECT to this CRect. operator ()
operator LPRECT();
Returns a pointer to the RECT associated with this CRect. operator ()
operator LPCRECT() const;
Returns a const pointer to the RECT associated with this CRect. operator ==
BOOL operator == (const RECT& rc) const;
Returns TRUE if the co-ordinates of the source rectangle and the CRect are equal. operator !=
BOOL operator != (const RECT& rc) const;
Returns TRUE if the of the source rectangle and the CRect are not equal. operator +=
void operator += (POINT pt);
void operator += (SIZE size);
void operator += (LPCRECT prc);
Adds the specified values to the CRect. operator -=
void operator -= (POINT pt);
void operator -= (SIZE sz);
void operator -= (LPCRECT prc);
Subtracts the specified values from the CRect. operator &=
void operator &= (const RECT& rc);
Determines the intersection with the specified RECT. operator |=
void operator |= (const RECT& rc);
Determines the union with the specified RECT. operator +
CRect operator + (POINT pt) const;
CRect operator + (SIZE sz) const;
CRect operator + (LPRECT prc) const;
Offsets the CRect and returns the result. operator -
CRect operator - (POINT pt) const;
CRect operator - (SIZE sz) const;
CRect operator - (LPRECT prc) const;
Offsets the CRect and returns the result. operator &
CRect operator & (const RECT& rc) const;
Returns the intersection with the specified RECT. operator |
CRect operator | (const RECT& rc) const;
Returns the union with the specified RECT. CopyRect
BOOL CopyRect(LPCRECT prc);
Copies the coordinates of the source rectangle to the CRect. DeflateRect
BOOL DeflateRect(int x, int y);
BOOL DeflateRect(SIZE size);
void DeflateRect(LPCRECT prc);
void DeflateRect(int l, int t, int r, int b);
Decreases the width and height of the CRect. EqualRect
BOOL EqualRect(LPRECT prc);
Determines whether the source rectangle and the CRect are equal by comparing the coordinates of their upper-left and lower-right corners. InflateRect
BOOL InflateRect(int dx, int dy);
BOOL InflateRect(SIZE sz);
void InflateRect(LPCRECT prc);
void InflateRect(int l, int t, int r, int b);
Increases the width and height of the CRect. IntersectRect
BOOL IntersectRect(LPCRECT prc1, LPCRECT prc2);
Calculates the intersection of two source rectangles and places the coordinates of the intersection rectange into the CRect. IsRectEmpty
BOOL IsRectEmpty() const;
Determines whether the CRect is empty. IsRectNull
BOOL IsRectNull() const;
Determines whether the CRect is NULL. MoveToX
void MoveToX (int x);
Moves the rect to the specified left position. MoveToY
void MoveToY (int y);
Moves the rect to the specified top position. MoveToXY
void MoveToXY (int x, int y);
void MoveToXY (POINT pt);
Moves to rect to the specified left and top positions. MulDiv
CRect MulDiv(int nMult, int nDiv) const;
Multiplies the CRect values by nMult, and then divides the result by nDiv. NormalizeRect
void NormalizeRect()
Normalizes CRect so that both the height and width are positive. OffsetRect
BOOL OffsetRect(int dx, int dy);
BOOL OffsetRect(POINT pt);
BOOL OffsetRect(SIZE size);
Moves the CRect by the specified offsets. PtInRect
BOOL PtInRect(POINT pt) const;
Determines whether the specified point lies within the CRect. SetRect
BOOL SetRect(int left, int top, int right, int bottom);
BOOL SetRect(POINT TopLeft, POINT BtmRight);
Sets the coordinates of the CRect. SetRectEmpty
BOOL SetRectEmpty();
Sets all the coordinates of the CRect to zero. SubtractRect
BOOL SubtractRect(LPCRECT prc1, LPCRECT prc2);
Sets the coordinates of the CRect to those formed by subtracting one rectangle from another. UnionRect
BOOL UnionRect(LPCRECT prc1, LPCRECT prc2);
Creates the union of two rectangles. Height
int Height() const;
Returns the height of the CRect. Width
int Width() const;
Returns the width of the CRect. Size
CSize Size() const;
Determines the size (width and height) of the CRect. CenterPoint
CPoint CenterPoint() const;
Returns the point at the center of the CRect. TopLeft
CPoint TopLeft() const;
Returns the top left point of the CRect. BottomRight
CPoint BottomRight() const;
Returns the bottom left point of the CRect.

Remarks

By default, the constructor sets all the rectangle coordinates zero, but the CRect can also be constructed from four integers, a rectangle, a point and size, or two points.

The CRect class inherits from the RECT structure.  As a result, the data members of the underlying RECT struct are also accessible as data members (left, top, right and bottom).

Summary Information

Header file winutils.h
Win32/64 support Yes
WinCE support Yes