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