StringFormat::GenericDefault method (gdiplusstringformat.h)

The StringFormat::GenericDefault method creates a generic, default StringFormat object.

Syntax

const StringFormat * GenericDefault();

Return value

Type: StringFormat*

This method returns a pointer to the new StringFormat object.

Remarks

A generic, default StringFormat object has the following characteristics:

  • No string format flags are set.
  • Character alignment and line alignment are set to StringAlignmentNear.
  • Language ID is set to neutral language, which means that the current language associated with the calling thread is used.
  • String digit substitution is set to StringDigitSubstituteUser.
  • Hot key prefix is set to HotkeyPrefixNone.
  • Number of tab stops is set to zero.
  • String trimming is set to StringTrimmingCharacter.

Examples

The following example creates a generic, default StringFormat object and then uses it to draw a formatted string. The code also draws the string's layout rectangle.

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);
}

Requirements

Requirement Value
Minimum supported client Windows XP, Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header gdiplusstringformat.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

Font

HotkeyPrefix

LOGFONT

RectF

StringAlignment

StringDigitSubstitute

StringFormat

StringFormatFlags

StringTrimming