Share via


Graphics::GetClipBounds (Rect*) 方法 (gdiplusgraphics.h)

Graphics::GetClipBounds 方法會取得矩形,此矩形會封入此 Graphics 物件的裁剪區域。

語法

Status GetClipBounds(
  [out] Rect *rect
);

參數

[out] rect

類型: Rect*

Rect 物件的指標,該物件會接收括住裁剪區域的矩形。

傳回值

類型: 狀態

如果方法成功,它會傳回Ok,這是 Status 列舉的元素。

如果方法失敗,它會傳回 Status 列舉的其他其中一個專案。

備註

世界轉換會套用至裁剪區域,然後計算封入矩形。

如果您未明確設定 Graphics 物件的裁剪區域,其裁剪區域是無限的。 當裁剪區域無限時, Graphics::GetClipBounds 會傳回大型矩形。 該矩形的 XY 數據成員是大型負數, 而 WidthHeight 數據成員是大正數。

範例

下列範例會設定裁剪區域、取得括住裁剪區域的矩形,然後填滿矩形。

VOID Example_GetClipBounds(HDC hdc)
{
   Graphics graphics(hdc);

   Region   myRegion(Rect(25, 25, 100, 50));
   Rect     rect(40, 60, 100, 50);
   Region   gRegion;
   Rect     enclosingRect;

   SolidBrush  blueBrush(Color(100, 0, 0, 255));
   Pen         greenPen(Color(255, 0, 255, 0), 1.5f);

   // Modify the region by using a rectangle.
   myRegion.Union(rect);

   // Set the clipping region of the graphics object.
   graphics.SetClip(&myRegion);

   // Now, get the clipping region, and fill it.
   graphics.GetClip(&gRegion);
   graphics.FillRegion(&blueBrush, &gRegion);

   // Get a rectangle that encloses the clipping region, and draw the enclosing
   // rectangle.
   graphics.GetClipBounds(&enclosingRect);
   graphics.ResetClip();
   graphics.DrawRectangle(&greenPen, enclosingRect);}

規格需求

需求
最低支援的用戶端 Windows XP、Windows 2000 Professional [僅限桌面應用程式]
最低支援的伺服器 Windows 2000 Server [僅限桌面應用程式]
目標平台 Windows
標頭 gdiplusgraphics.h (包含 Gdiplus.h)
程式庫 Gdiplus.lib
Dll Gdiplus.dll

另請參閱

裁剪

使用區域裁剪

GetVisibleClipBounds 方法

圖形

Graphics::GetClip

Rect

SetClip 方法

狀態