Share via


Graphics::D rawPolygon (constPen*,constPointF*,INT) 方法 (gdiplusgraphics.h)

Graphics::D rawPolygon方法繪製多邊形。

語法

Status DrawPolygon(
  const Pen    *pen,
  const PointF *points,
  INT          count
);

參數

pen

用來繪製多邊形的畫筆指標。

points

PointF物件的陣列指標,指定多邊形的頂點。

count

整數,指定 陣列中的專案數目。

傳回值

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

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

備註

如果 陣列中的第一個和最後一個座標不相同,則會在兩者之間繪製線條來關閉多邊形。

範例

下列範例會繪製由點陣列定義的多邊形。

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

   // Create a Pen object.
   Pen blackPen(Color(255, 0, 0, 0), 3);

   // Create an array of PointF objects that define the polygon.
   PointF point1(100.0f, 100.0f);
   PointF point2(200.0f, 130.0f);
   PointF point3(150.0f, 200.0f);
   PointF point4(50.0f, 200.0f);
   PointF point5(0.0f, 130.0f);
   PointF points[5] = {point1, point2, point3, point4, point5};
   PointF* pPoints = points;

   // Draw the polygon.
   graphics.DrawPolygon(&blackPen, pPoints, 5);
}

需求

   
標頭 gdiplusgraphics.h

另請參閱

FillPolygon 方法

圖形

PointF

多邊形