Partager via


CDC::DrawTextEx

Formats text in the given rectangle.

virtual int DrawTextEx( 
   LPTSTR lpszString, 
   int nCount, 
   LPRECT lpRect, 
   UINT nFormat,
   LPDRAWTEXTPARAMS lpDTParams 
); 
int DrawTextEx( 
   const CString& str, 
   LPRECT lpRect, 
   UINT nFormat,
   LPDRAWTEXTPARAMS lpDTParams 
);

Parameters

  • lpszString
    Points to the string to be drawn. If nCount is –1, the string must be null terminated.

  • nCount
    Specifies the number of chars in the string. If nCount is –1, then lpszString is assumed to be a long pointer to a null-terminated string and DrawText computes the character count automatically.

  • lpRect
    Points to a RECT structure or CRect object that contains the rectangle (in logical coordinates) in which the text is to be formatted.

  • str
    A CString object that contains the specified characters to be drawn.

  • nFormat
    Specifies the method of formatting the text. It can be any combination of the values described for the uFormat parameter in DrawText in the Windows SDK. (Combine using the bitwise OR operator):

    Note

    Some uFormat flag combinations can cause the passed string to be modified. Using DT_MODIFYSTRING with either DT_END_ELLIPSIS or DT_PATH_ELLIPSIS may cause the string to be modified, causing an assertion in the CString override. The values DT_CALCRECT, DT_EXTERNALLEADING, DT_INTERNAL, DT_NOCLIP, and DT_NOPREFIX cannot be used with the DT_TABSTOP value.

  • lpDTParams
    Pointer to a DRAWTEXTPARAMS structure that specifies additional formatting options. This parameter can be NULL.

Remarks

It formats text by expanding tabs into appropriate spaces, aligning text to the left, right, or center of the given rectangle, and breaking text into lines that fit within the given rectangle. The type of formatting is specified by nFormat and lpDTParams. For more information, see CDC::DrawText and DrawTextEx in the Windows SDK.

The text color may be set by CDC::SetTextColor.

Requirements

Header: afxwin.h

See Also

Reference

CDC Class

Hierarchy Chart

CDC::DrawText

CDC::ExtTextOut

CDC::TabbedTextOut

CDC::TextOut

DrawText

RECT Structure

CDC::SetTextAlign