Region::GetBounds(RectF*,constGraphics*) method (gdiplusheaders.h)

The Region::GetBounds method gets a rectangle that encloses this region.

Syntax

Status GetBounds(
  [out] RectF          *rect,
  [in]  const Graphics *g
);

Parameters

[out] rect

Type: RectF*

Pointer to a RectF object that receives the enclosing rectangle.

[in] g

Type: const Graphics*

Pointer to a Graphics object that contains the world and page transformations required to calculate the device coordinates of this region and the rectangle.

Return value

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.

Remarks

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.

Examples

The following example creates a region from a path, gets the region's enclosing rectangle, and then displays both.

VOID Example_GetBoundsRectF(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));
    RectF 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);
}

Requirements

Requirement Value
Minimum supported client Windows XP, Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header gdiplusheaders.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

GraphicsPath

Region