Share via


Graphics::D rawLine (constPen*,REAL,REAL,REAL,REAL,REAL,REAL) 方法 (gdiplusgraphics.h)

Graphics::D rawLine方法繪製連接兩點的線條。

語法

Status DrawLine(
  const Pen *pen,
  REAL      x1,
  REAL      y1,
  REAL      x2,
  REAL      y2
);

參數

pen

用來繪製線條的手寫筆指標。

x1

指定線條起點 X 座標的實數。

y1

指定線條起點的 Y 座標的實數。

x2

指定線條結束點 X 座標的實數。

y2

指定線條結束點的 Y 座標的實數。

傳回值

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

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

備註

範例

下列範例會繪製線條。

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

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

   // Initialize the coordinates of the points that define the line.
   REAL x1 = 100.0f;
   REAL y1 = 100.0f;
   REAL x2 = 500.0f;
   REAL y2 = 100.0f;

   // Draw the line.
   graphics.DrawLine(&blackPen, x1, y1, x2, y2);
}

需求

   
標頭 gdiplusgraphics.h

另請參閱

DrawLines 方法

圖形

畫筆、線條和矩形

PointF

使用畫筆繪製線條和矩形