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

Region::GetBounds 方法获取一个包含此区域的矩形。

语法

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

参数

[out] rect

类型: RectF*

指向接收封闭矩形的 RectF 对象的指针。

[in] g

类型: const Graphics*

指向 Graphics 对象的指针,该对象包含计算此区域和矩形的设备坐标所需的世界和页面转换。

返回值

类型: 状态

如果方法成功,则返回 Ok,这是 Status 枚举的元素。

如果 方法失败,它将返回 Status 枚举的其他元素之一。

注解

图形对象的当前世界和页面转换用于计算在显示设备上绘制的区域和矩形。 Region::GetBounds 返回的矩形并不总是尽可能小的矩形。

示例

以下示例从路径创建一个区域,获取该区域的封闭矩形,然后同时显示这两个矩形。

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);
}

要求

要求
最低受支持的客户端 Windows XP、Windows 2000 Professional [仅限桌面应用]
最低受支持的服务器 Windows 2000 Server [仅限桌面应用]
目标平台 Windows
标头 gdiplusheaders.h (包括 Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

另请参阅

GraphicsPath

区域