Region::GetHRGN 方法 (gdiplusheaders.h)

Region::GetHRGN 方法从此区域创建 Windows 图形设备接口 (GDI) 区域。

语法

HRGN GetHRGN(
  [in] const Graphics *g
);

参数

[in] g

类型: const Graphics*

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

返回值

类型: HRGN

此方法返回从该区域创建的 GDI 区域的 Windows 句柄。

注解

调用方负责调用 GDI 函数 DeleteObject ,以在不再需要 GDI 区域时释放它。

示例

以下示例从路径创建 GDI+ 区域,然后使用 GDI+ 区域创建 GDI 区域。 然后,代码使用 GDI 函数显示 GDI 区域。

VOID Example_GetHRGN(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;
   path.AddClosedCurve(points, 6);

    // Create a region from a path.
    Region pathRegion(&path);

   // Get a handle to a GDI region.
   HRGN hRegion;
   hRegion = pathRegion.GetHRGN(&graphics);

   // Use GDI to display the region.
   HBRUSH hBrush = CreateSolidBrush(RGB(255, 0, 0));
   FillRgn(hdc, hRegion, hBrush);

   DeleteObject(hBrush);
   DeleteObject(hRegion);
}

要求

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

另请参阅

DeleteObject

显卡

Rect

区域