次の方法で共有


StringFormat::GenericDefault メソッド (gdiplusstringformat.h)

StringFormat::GenericDefault メソッドは、汎用の既定の StringFormat オブジェクトを作成します。

構文

const StringFormat * GenericDefault();

戻り値

型: StringFormat*

このメソッドは、新しい StringFormat オブジェクトへのポインターを返します。

解説

汎用の既定 の StringFormat オブジェクトには、次の特性があります。

  • 文字列書式フラグは設定されません。
  • 文字の配置と線の配置は StringAlignmentNear に設定されます。
  • 言語 ID はニュートラル言語に設定されています。つまり、呼び出し元のスレッドに関連付けられている現在の言語が使用されます。
  • 文字列の数字の置換は StringDigitSubstituteUser に設定されます。
  • ホット キー プレフィックスが HotkeyPrefixNone に設定されています。
  • タブ位置の数が 0 に設定されています。
  • 文字列トリミングは StringTrimmingCharacter に設定されています。

次の例では、汎用の既定 の StringFormat オブジェクトを作成し、それを使用して書式設定された文字列を描画します。 このコードでは、文字列のレイアウト四角形も描画されます。

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

   SolidBrush  solidBrush(Color(255, 255, 0, 0)); 
   FontFamily  fontFamily(L"Times New Roman");
   Font        font(&fontFamily, 12, FontStyleRegular, UnitPoint);
   
   // Create a generic StringFormat object.
   const StringFormat* pStringFormat = StringFormat::GenericDefault();

   // Use the generic StringFormat object in a call to DrawString.
  graphics.DrawString(
      L"This text was formatted by a generic StringFormat object.", 
      57,  // string length
      &font, 
      RectF(30, 30, 100, 120), 
      pStringFormat, 
      &solidBrush);

   // Draw the rectangle that encloses the text.
   Pen pen(Color(255, 255, 0, 0));
   graphics.DrawRectangle(&pen, 30, 30, 100, 120);
}

要件

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

関連項目

フォント

HotkeyPrefix

Logfont

RectF

StringAlignment

StringDigitSubstitute

StringFormat

StringFormatFlags

StringTrimming