Share via


Pen::SetDashStyle メソッド (gdipluspen.h)

Pen::SetDashStyle メソッドは、この Pen オブジェクトのダッシュ スタイルを設定します。

構文

Status SetDashStyle(
  [in] DashStyle dashStyle
);

パラメーター

[in] dashStyle

種類: DashStyle

この Pen オブジェクトのダッシュ スタイルを指定する DashStyle 列挙体の要素。

戻り値

種類: 状態

メソッドが成功した場合は、Status 列挙の要素である Ok を返します

メソッドが失敗した場合は、 Status 列挙体の他の要素のいずれかを返します。

注釈

破線のダッシュの長さは、破線のスタイルと Pen オブジェクトの幅によって異なります。 破線で 2 つのダッシュを区切るスペースの長さは、 Pen オブジェクトの幅と等しくなります。

次の使用例は、 Pen オブジェクトを作成し、破線のスタイルを設定し、線を描画します。 次に、ダッシュ スタイルをリセットし、2 番目の線を描画し、もう一度ダッシュ スタイルをリセットして、3 番目の線を描画します。

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

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

   // Set the dash style for the pen, and draw a dashed line.
   pen.SetDashStyle(DashStyleDash);
   graphics.DrawLine(&pen, 0, 50, 400, 150);

   // Reset the dash style for the pen, and draw a second line.
   pen.SetDashStyle(DashStyleDot);
   graphics.DrawLine(&pen, 0, 80, 400, 180); 

   // Reset the dash style for the pen, and draw a third line.
   pen.SetDashStyle(DashStyleDashDot);
   graphics.DrawLine(&pen, 0, 110, 400, 210); 
}

要件

要件
サポートされている最小のクライアント Windows XP、Windows 2000 Professional [デスクトップ アプリのみ]
サポートされている最小のサーバー Windows 2000 Server [デスクトップ アプリのみ]
対象プラットフォーム Windows
ヘッダー gdipluspen.h (Gdiplus.h を含む)
Library Gdiplus.lib
[DLL] Gdiplus.dll

こちらもご覧ください

ユーザー設定の破線の描画

ペン

Pen::GetDashCap

Pen::GetDashOffset

Pen::GetDashPattern

Pen::GetDashPatternCount

Pen::GetDashStyle

Pen::SetDashCap

Pen::SetDashOffset

Pen::SetDashPattern

ペン、直線、および四角形