Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
The Region::GetBounds method gets a rectangle that encloses this region.
Status GetBounds(
Rect *rect,
const Graphics *g
);
rect
Pointer to a Rect object that receives the enclosing rectangle.
g
Pointer to a Graphics object that contains the world and page transformations required to calculate the device coordinates of this region and the rectangle.
Type: Status
If the method succeeds, it returns Ok, which is an element of the Status enumeration.
If the method fails, it returns one of the other elements of the Status enumeration.
The current world and page transformations of the graphics object are used to calculate the region and the rectangle as they are drawn on the display device. The rectangle returned by Region::GetBounds is not always the smallest possible rectangle.
The following example creates a region from a path, gets the region's enclosing rectangle, and then displays both.
VOID Example_GetBoundsRect(HDC hdc)
{
Graphics graphics(hdc);
Point points[] = {
Point(110, 20),
Point(120, 30),
Point(100, 60),
Point(120, 70),
Point(150, 60),
Point(140, 10)};
GraphicsPath path;
SolidBrush solidBrush(Color(255, 255, 0, 0));
Pen pen(Color(255, 0, 0, 0));
Rect rect;
path.AddClosedCurve(points, 6);
// Create a region from a path.
Region pathRegion(&path);
// Get the region's enclosing rectangle.
pathRegion.GetBounds(&rect, &graphics);
// Show the region and the enclosing rectangle.
graphics.FillRegion(&solidBrush, &pathRegion);
graphics.DrawRectangle(&pen, rect);
}
Requirement | Value |
---|---|
Header | gdiplusheaders.h |
Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register today