System::Drawing::Rectangle class

Rectangle class

Represents a rectangular area of an image defined as integer X and Y coordinates of its upper left corner and its width and height. This type should be allocated on stack and passed to functions by value or by reference. Never use System::SmartPtr class to manage objects of this type.

class Rectangle

Methods

MethodDescription
static Ceiling(const RectangleF&)Constructs a Rectangle object from the specified RectangleF object by rounding the RectangleF object’s location and size values to the next higher integer values.
Contains(int, int) constDetermines if the specified point is located within the rectangle represented by the current object.
Contains(const Point&) constDetermines if the specified point is located within the rectangle represented by the current object.
Contains(const Rectangle&) constDetermines if the specified rectangle is located within the rectangle represented by the current object.
Equals(const Rectangle&) constDetermines if the rectangles represented by the current and the specified objects are identical.
static FromLTRB(int, int, int, int)Constructs a new Rectangle object that represents a rectangle with the specified edge locations.
get_Bottom() constReturns the y coordinate of the bottom edge of the rectangle represented by the current object.
get_Height() constReturns the height of the rectangle represented by the current object.
get_IsEmpty() constDetermines if X and Y coordinates of the upper left corner of the recangle represented by the current object as well as its width and height have values of 0.
get_Left() constReturns the X coordinate of the left edge of the rectangle represented by the current object.
get_Location() constReturns an instance of the Point class that specifies the location of the upper left corner of the rectangle represented by the current object.
get_Right() constReturns the X coordinate of the right edge of the rectangle represented by the current object.
get_Size() constReturns an instance of the Size class that specifies the width and height of the rectangle represented by the current object.
get_Top() constReturns the Y coordinate of the top edge of the rectangle represented by the current object.
get_Width() constReturns the width of the rectangle represented by the current object.
get_X() constReturns the X coordinate of the upper left corner of the rectangle represented by the current object.
get_Y() constReturns the Y coordinate of the upper left corner of the rectangle represented by the current object.
GetHashCode() constReturns a hash code of the current object.
Inflate(int, int)Increases the width and height of the rectangle represented by the current object, maintaining the location of the geometrical center of the rectangle. The width and height are increased in both directions by the specified amounts.
Inflate(const Size&)Increases the width and height of the rectangle represented by the current object, maintaining the location of the geometrical center of the rectangle. The width and height are increased in both directions by the amounts specified by width and height values of the specified size object correspondingly.
static Inflate(const Rectangle&, int, int)Increases the width and height of the rectangle represented by the specified object, maintaining the location of the geometrical center of the rectangle. The width and height are increased in both directions by the specified amounts.
Intersect(const Rectangle&)Replaces the rectangle represented by the current object with the rectangle that results from the its intersection with the rectangle represented by the specified object.
static Intersect(const Rectangle&, const Rectangle&)Returns a rectangle that is a result of intersection of the specified rectangles.
IntersectsWith(const Rectangle&)Determines if the rectangles represented by the current and specified objects intesect.
Offset(const Point&)Offsets the position of the rectangle represented by the current object by the specified amounts.
Offset(int, int)Offsets the position of the rectangle represented by the current object by the specified amounts.
operator RectangleF() constReturns a RectangleF object that represents a rectangle equivalent to the rectangle represented by the current object.
operator!=(std::nullptr_t) constAlways returns true.
operator==(std::nullptr_t) constAlways returns false.
Rectangle()Constructs a new instance of Rectangle object that represents a rectangle with X and Y coordinates and width and hegiht values set to 0.
Rectangle(int, int, int, int)Constructs a new instance of Rectangle object that represents a rectangle with the specified coordinates of its upper left corner and width and height.
Rectangle(const Point&, const Size&)Constructs a new instance of Rectangle object that represents a rectangle with the coordinates of its upper left corner specified as an instance of Point class and its width and height as an instance of Size class.
Rectangle(const System::Windows::Forms::Screen::Rectangle_&)Constructs a new instance of Rectangle object that represents the rectangle equivalent to the specified one.
static Round(const RectangleF&)Constructs a Rectangle object from the specified RectangleF object by rounding the RectangleF object’s location and size values to the nearest integer values.
set_Height(int)Sets the height of the rectangle represented by the current object.
set_Location(Point)Sets the location of the upper left corner of the rectangle represented by the current object.
set_Size(Size)Sets the width and height of the rectangle represented by the current object.
set_Width(int)Sets the width of the rectangle represented by the current object.
set_X(int)Sets the X coordinate of the upper left corner of the rectangle represented by the current object.
set_Y(int)Sets the Y coordinate of the upper left corner of the rectangle represented by the current object.
ToString() constReturns the string representation of the current object.
static Truncate(const RectangleF&)Constructs a Rectangle object from the specified RectangleF object by truncating the RectangleF object’s location and size values to the next lower integer values.
static Union(const Rectangle&, const Rectangle&)Returns a rectangle that is a result of union of the specified rectangles.

Fields

FieldDescription
static EmptyAn empty rectangle i.e. a rectangle whose location and size values have zero values.

See Also