StringFormat::GenericDefault 方法 (gdiplusstringformat.h)

StringFormat::GenericDefault方法會建立泛型的預設StringFormat物件。

Syntax

const StringFormat * GenericDefault();

傳回值

類型: StringFormat*

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

備註

泛型的預設 StringFormat 物件具有下列特性:

  • 未設定任何字串格式旗標。
  • 字元對齊和行對齊設定為 StringAlignmentNear。
  • 語言識別項設定為中性語言,這表示會使用與呼叫執行緒相關聯的目前語言。
  • 字串數位替代設定為 StringDigitSubstituteUser。
  • 熱鍵前置詞會設定為 HotkeyPrefixNone。
  • 定位停駐點的數目會設定為零。
  • 字串修剪設定為 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)
程式庫 Gdiplus.lib
Dll Gdiplus.dll

另請參閱

字型

HotkeyPrefix

LOGFONT

RectF

StringAlignment

StringDigitSubstitute

StringFormat

StringFormatFlags

StringTrimming