Pen::SetDashCap 方法 (gdipluspen.h)

Pen::SetDashCap方法會設定此Pen物件的虛線上限樣式。

語法

Status SetDashCap(
  [in] DashCap dashCap
);

參數

[in] dashCap

類型: DashCap

DashCap列舉的 元素,指定這個Pen物件的虛線端點。

傳回值

類型: 狀態

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

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

備註

如果您將 Pen 物件的對齊方式設定為 PenAlignmentInset,就無法使用該畫筆繪製三角形虛線端點。

範例

下列範例會建立 Pen 物件、設定虛線樣式和虛線上限,並繪製虛線。

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

   // Create a pen.
   Pen pen(Color(255, 0, 0, 255), 20);

   // Set the dash style for the pen.
   pen.SetDashStyle(DashStyleDash);

   // Set a triangular dash cap for the pen.
   pen.SetDashCap(DashCapTriangle);

   // Draw a line using the pen.
   graphics.DrawLine(&pen, 20, 20, 200, 100);
}

需求

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

另請參閱

繪製自訂虛線

使用線條大寫繪製線條

Pen::GetCustomEndCap

Pen::GetCustomStartCap

Pen::GetDashCap

畫筆、線條和矩形