CRect Class
Similar to a Windows RECT structure.
class CRect : public tagRECT
Members
Public Constructors
Name |
Description |
---|---|
Constructs a CRect object. |
Public Methods
Name |
Description |
---|---|
Returns the bottom-right point of CRect. |
|
Returns the centerpoint of CRect. |
|
Copies the dimensions of a source rectangle to CRect. |
|
Decreases the width and height of CRect. |
|
Determines whether CRect is equal to the given rectangle. |
|
Calculates the height of CRect. |
|
Increases the width and height of CRect. |
|
Sets CRect equal to the intersection of two rectangles. |
|
Determines whether CRect is empty. CRect is empty if the width and/or height are 0. |
|
Determines whether the top, bottom, left, and right member variables are all equal to 0. |
|
Moves CRect to the specified x-coordinate. |
|
Moves CRect to the specified x- and y-coordinates. |
|
Moves CRect to the specified y-coordinate. |
|
Standardizes the height and width of CRect. |
|
Moves CRect by the specified offsets. |
|
Determines whether the specified point lies within CRect. |
|
Sets the dimensions of CRect. |
|
Sets CRect to an empty rectangle (all coordinates equal to 0). |
|
Calculates the size of CRect. |
|
Subtracts one rectangle from another. |
|
Returns the top-left point of CRect. |
|
Sets CRect equal to the union of two rectangles. |
|
Calculates the width of CRect. |
Public Operators
Name |
Description |
---|---|
Subtracts the given offsets from CRect or deflates CRect and returns the resulting CRect. |
|
Converts a CRect to an LPCRECT. |
|
Converts a CRect to an LPRECT. |
|
Determines whether CRect is not equal to a rectangle. |
|
Creates the intersection of CRect and a rectangle and returns the resulting CRect. |
|
Sets CRect equal to the intersection of CRect and a rectangle. |
|
Creates the union of CRect and a rectangle and returns the resulting CRect. |
|
Sets CRect equal to the union of CRect and a rectangle. |
|
Adds the given offsets to CRect or inflates CRect and returns the resulting CRect. |
|
Adds the specified offsets to CRect or inflates CRect. |
|
Copies the dimensions of a rectangle to CRect. |
|
Subtracts the specified offsets from CRect or deflates CRect. |
|
Determines whether CRect is equal to a rectangle. |
Remarks
CRect also includes member functions to manipulate CRect objects and Windows RECT structures.
A CRect object can be passed as a function parameter wherever a RECT structure, LPCRECT, or LPRECT can be passed.
Note
This class is derived from the tagRECT structure. (The name tagRECT is a less-commonly-used name for the RECT structure.) This means that the data members (left, top, right, and bottom) of the RECT structure are accessible data members of CRect.
A CRect contains member variables that define the top-left and bottom-right points of a rectangle.
When specifying a CRect, you must be careful to construct it so that it is normalized — in other words, such that the value of the left coordinate is less than the right and the top is less than the bottom. For example, a top left of (10,10) and bottom right of (20,20) defines a normalized rectangle but a top left of (20,20) and bottom right of (10,10) defines a non-normalized rectangle. If the rectangle is not normalized, many CRect member functions may return incorrect results. (See CRect::NormalizeRect for a list of these functions.) Before you call a function that requires normalized rectangles, you can normalize non-normalized rectangles by calling the NormalizeRect function.
Use caution when manipulating a CRect with the CDC::DPtoLP and CDC::LPtoDP member functions. If the mapping mode of a display context is such that the y-extent is negative, as in MM_LOENGLISH, then CDC::DPtoLP will transform the CRect so that its top is greater than the bottom. Functions such as Height and Size will then return negative values for the height of the transformed CRect, and the rectangle will be non-normalized.
When using overloaded CRect operators, the first operand must be a CRect; the second can be either a RECT structure or a CRect object.
Note
For more information on shared utility classes (like CRect), see Shared Classes.
Inheritance Hierarchy
tagRECT
CRect
Requirements
Header: atltypes.h