StringFormat::GenericTypographic 方法 (gdiplusstringformat.h)

StringFormat::GenericTypographic 方法會建立泛型印刷樣式 StringFormat 物件。

Syntax

const StringFormat * GenericTypographic();

傳回值

類型: StringFormat*

這個方法會傳回新 StringFormat 物件的指標。

備註

泛型印刷 樣式 StringFormat 物件具有下列特性:

  • 已設定字串格式旗標 StringFormatFlagsLineLimit、StringFormatFlagsNoClip 和 StringFormatFlagsNoFitBlackBox。
  • 字元對齊和線條對齊設定為 StringAlignmentNear。
  • 語言標識符設定為中性語言,這表示會使用與呼叫線程相關聯的目前語言。
  • 字串數位替代設定為 StringDigitSubstituteUser。
  • 熱鍵前置詞設定為 HotkeyPrefixNone。
  • 製表位的數目設定為零。
  • 字串修剪設定為 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)
程式庫 Gdiplus.lib
Dll Gdiplus.dll

另請參閱

字型

HotkeyPrefix

LOGFONT

RectF

StringAlignment

StringDigitSubstitute

StringFormat

StringFormatFlags

StringTrimming