0% found this document useful (0 votes)
18 views5 pages

CRect Class

Uploaded by

bennetcharles
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views5 pages

CRect Class

Uploaded by

bennetcharles
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

CRect Class

Similar to a Windows RECT structure

class CRect : public tagRECT

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.

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

The RECT structure defines the coordinates of the upper-left and lower-right corners of a
rectangle.

typedef struct tagRECT {


LONG left;
LONG top;
LONG right;
LONG bottom;
} RECT;

Construction

CRect Constructs a CRect object.


Operations

BottomRight Returns the bottom-right point of CRect.

CenterPoint Returns the centerpoint of CRect.

CopyRect Copies the dimensions of a source rectangle to CRect.

DeflateRect Decreases the width and height of CRect.

EqualRect Determines whether CRect is equal to the given rectangle.

Height Calculates the height of CRect.


InflateRect Increases the width and height of CRect.

IntersectRect Sets CRect equal to the intersection of two rectangles.

Determines whether CRect is empty. CRect is empty if the width and/or


IsRectEmpty
height are 0.

Determines whether the top, bottom, left, and right member variables are
IsRectNull
all equal to 0.

MoveToX Moves CRect to the specified x-coordinate.

MoveToXY Moves CRect to the specified x- and y-coordinates.

MoveToY Moves CRect to the specified y-coordinate.

NormalizeRect Standardizes the height and width of CRect.

OffsetRect Moves CRect by the specified offsets.

PtInRect Determines whether the specified point lies within CRect.

SetRect Sets the dimensions of CRect.

SetRectEmpty Sets CRect to an empty rectangle (all coordinates equal to 0).

Size Calculates the size of CRect.

SubtractRect Subtracts one rectangle from another.

TopLeft Returns the top-left point of CRect.

UnionRect Sets CRect equal to the union of two rectangles.

Width Calculates the width of CRect.


Operators

operator != Determines whether CRect is not equal to a rectangle.

Creates the intersection of CRect and a rectangle and returns the


operator &
resulting CRect.

operator &= Sets CRect equal to the intersection of CRect and a rectangle.
Subtracts the given offsets from CRect or deflates CRect and returns
operator –
the resulting CRect.

Creates the union of CRect and a rectangle and returns the resulting
operator |
CRect.

operator |= Sets CRect equal to the union of CRect and a rectangle.

Adds the given offsets to CRect or inflates CRect and returns the
operator +
resulting CRect.

operator += Adds the specified offsets to CRect or inflates CRect.

operator = Copies the dimensions of a rectangle to CRect.

operator –= Subtracts the specified offsets from CRect or deflates CRect.

operator == Determines whether CRect is equal to a rectangle.

operator
Converts a CRect to an LPCRECT.
LPCRECT

operator
Converts a CRect to an LPRECT.
LPRECT

CRect Member Functions

CRect::BottomRight - The coordinates of the bottom-right corner of the rectangle.

CRect::CenterPoint - Calculates the centerpoint of CRect by adding the left and right
values and dividing by two, and adding the top and bottom values and dividing by two.

CRect::CopyRect
CRect::CRect

CRect::DeflateRect

CRect::EqualRect

CRect::Height

CRect::InflateRect

CRect::IntersectRect

CRect::IsRectEmpty

CRect::IsRectNull

CRect::MoveToX

CRect::MoveToXY

CRect::MoveToY

CRect::NormalizeRect

CRect::OffsetRect

CRect::PtInRect

CRect::SetRect

CRect::SetRectEmpty

CRect::Size

CRect::SubtractRect

CRect::TopLeft

CRect::UnionRect

CRect::Width

You might also like