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

Pen::GetDashPattern メソッドは、この Pen オブジェクトに現在設定されているカスタム ダッシュとスペースの配列を取得します。

構文

Status GetDashPattern(
  [out] REAL *dashArray,
  [in]  INT  count
);

パラメーター

[out] dashArray

種類: REAL*

カスタム破線のダッシュとスペースの長さを受け取る配列へのポインター。

[in] count

型: INT

dashArray 配列内の要素の数を指定する整数。

戻り値

種類: 状態

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

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

解説

dashArray 配列の要素は、ダッシュ パターン内の各ダッシュとスペースの長さを設定します。 最初の要素はダッシュの長さを設定し、2 番目の要素はスペースの長さを設定し、3 番目の要素はダッシュの長さを設定します。

ダッシュ パターンの各ダッシュとスペースの長さは、配列内の各要素の積と Pen オブジェクトの幅です。

次の例では、実数と Pen オブジェクトの配列を作成し、ダッシュ パターンを設定し、ユーザー設定の破線を描画します。 その後、コードはペンに現在設定されているダッシュ パターンを取得します。

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

   // Create a custom dashed pen, and use it to draw a line.
   REAL dashVals[4] = {5, 2, 15, 4};
   Pen pen(Color(255, 0, 0, 0), 5);
   pen.SetDashPattern(dashVals, 4);
   graphics.DrawLine(&pen, 5, 20, 405, 200);

   // Obtain information about the pen.
   INT count = 0;
   REAL* dashValues = NULL;

   count = pen.GetDashPatternCount();
   dashValues = new REAL[count];
   pen.GetDashPattern(dashValues, count);

   for(INT j = 0; j < count; ++j)
   {
      // Inspect or use the value in dashValues[j].
   }
   delete [] dashValues;
}

要件

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

関連項目

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

ペン

Pen::GetDashPatternCount

Pen::SetDashPattern

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