次の方法で共有


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

StringFormat::GenericTypographic メソッドは、汎用の文字体裁 StringFormat オブジェクトを作成します。

構文

const StringFormat * GenericTypographic();

戻り値

型: StringFormat*

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

注釈

汎用の文字体裁 StringFormat オブジェクトには、次の特性があります。

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

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

VOID Example_GenericTypographic(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 typographic StringFormat object.
   const StringFormat* pStringFormat = StringFormat::GenericTypographic();
   // Use the generic typographic StringFormat object 
   // in a call to DrawString.
  graphics.DrawString(
      L"Formatted by a generic typographic StringFormat object", 
      54,  // 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