Share via


StringFormat::GenericDefault, méthode (gdiplusstringformat.h)

La méthode StringFormat::GenericDefault crée un objet StringFormat générique par défaut.

Syntaxe

const StringFormat * GenericDefault();

Valeur de retour

Type : StringFormat*

Cette méthode retourne un pointeur vers le nouvel objet StringFormat .

Notes

Un objet StringFormat générique par défaut présente les caractéristiques suivantes :

  • Aucun indicateur de format de chaîne n’est défini.
  • L’alignement des caractères et l’alignement des lignes sont définis sur StringAlignmentNear.
  • L’ID de langue est défini sur une langue neutre, ce qui signifie que la langue actuelle associée au thread appelant est utilisée.
  • La substitution de chiffres de chaîne est définie sur StringDigitSubstituteUser.
  • Le préfixe de la touche rapide est défini sur HotkeyPrefixNone.
  • Le nombre de taquets de tabulation est défini sur zéro.
  • Le découpage de chaîne est défini sur StringTrimmingCharacter.

Exemples

L’exemple suivant crée un objet StringFormat générique par défaut, puis l’utilise pour dessiner une chaîne mise en forme. Le code dessine également le rectangle de disposition de la chaîne.

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

Configuration requise

   
Client minimal pris en charge Windows XP, Windows 2000 Professionnel [applications de bureau uniquement]
Serveur minimal pris en charge Windows 2000 Server [applications de bureau uniquement]
Plateforme cible Windows
En-tête gdiplusstringformat.h (inclure Gdiplus.h)
Bibliothèque Gdiplus.lib
DLL Gdiplus.dll

Voir aussi

Police

HotkeyPrefix

LOGFONT

RectF

StringAlignment

StringDigitSubstitute

StringFormat

StringFormatFlags

StringTrimming