?/TD>
Microsoft DirectX 9.0

ID3DXFont::DrawText Method


Draws formatted text. This method supports ANSI and Unicode strings.

Syntax

INT DrawText(      

    LPCSTR pString,     INT Count,     LPRECT pRect,     DWORD Format,     D3DCOLOR Color );

Parameters

pString
[in] Pointer to a string to draw. This parameter supports ANSI and Unicode text strings. If UNICODE or _UNICODE is defined, the string must be of type LPCWSTR, otherwise, the string must be of type LPCSTR.

If the Count parameter is -1, the string must be null-terminated.

If Format includes DT_MODIFYSTRING, the function could add up to four additional characters to this string. The buffer containing the string should be large enough to accommodate these extra characters.
Count
[in] Specifies the number of characters in the string. If Count is -1, then the pString parameter is assumed to be a pointer to a null-terminated string and ID3DXFont::DrawText computes the character count automatically.
pRect
[in] Pointer to a RECT structure that contains the rectangle, in logical coordinates, in which the text is to be formatted.
Format
[in] Specifies the method of formatting the text. It can be any combination of the following values.
DT_BOTTOM
Justifies the text to the bottom of the rectangle. This value must be combined with DT_SINGLELINE.
DT_CALCRECT
Determines the width and height of the rectangle. If there are multiple lines of text, ID3DXFont::DrawText uses the width of the rectangle pointed to by the pRect parameter and extends the base of the rectangle to bound the last line of text. If there is only one line of text, ID3DXFont::DrawText modifies the right side of the rectangle so that it bounds the last character in the line. In either case, ID3DXFont::DrawText returns the height of the formatted text but does not draw the text.
DT_CENTER
Centers text horizontally in the rectangle.
DT_EDITCONTROL
Duplicates the text-displaying characteristics of a multiline edit control. Specifically, the average character width is calculated in the same manner as for an edit control, and the function does not display a partially visible last line.
DT_END_ELLIPSIS or DT_PATH_ELLIPSIS

Truncates the string without adding ellipses so that the result fits in the specified rectangle. The string is not modified unless the DT_MODIFYSTRING flag is specified.

Specify DT_END_ELLIPSIS to truncate characters at the end of the string, or DT_PATH_ELLIPSIS to truncate characters in the middle of the string. If the string contains backslash (\) characters, DT_PATH_ELLIPSIS preserves as much of the text as possible after the last backslash.

DT_EXPANDTABS
Expands tab characters. The default number of characters per tab is eight. The DT_WORD_ELLIPSIS, DT_PATH_ELLIPSIS, and DT_END_ELLIPSIS values cannot be used with the DT_EXPANDTABS value.
DT_EXTERNALLEADING
Includes the font external leading in line height. Normally, external leading is not included in the height of a line of text.
DT_HIDEPREFIX
Microsoft?Windows?2000: Ignores the ampersand prefix character in the text. The letter that follows is not underlined, but other mnemonic-prefix characters are still processed.

Example:

input string: "A&bc&&d"

normal: "A&d"

HIDEPREFIX: "Abc&d"

Compare with DT_NOPREFIX and DT_PREFIXONLY.

DT_INTERNAL
Uses the system font to calculate text metrics.
DT_LEFT
Aligns text to the left.
DT_MODIFYSTRING
Modifies the string to match the displayed text. This flag has no effect unless the DT_END_ELLIPSIS or DT_PATH_ELLIPSIS flag is specified.
DT_NOCLIP
Draws without clipping. ID3DXFont::DrawText is somewhat faster when DT_NOCLIP is used.
DT_NOFULLWIDTHCHARBREAK
Windows 98, Windows 2000: Prevents a line break at a double-byte character set (DBCS), so that the line-breaking rule is equivalent to a single-byte character set (SBCS). For example, this can be used in Korean windows for more readability of icon labels. This is effective only if DT_WORDBREAK is specified.
DT_NOPREFIX
Turns off processing of prefix characters. Normally, ID3DXFont::DrawText interprets the mnemonic-prefix character & as a directive to underscore the character that follows, and the mnemonic-prefix characters && as a directive to print a single &. By specifying DT_NOPREFIX, this processing is turned off. Compare with DT_HIDEPREFIX and DT_PREFIXONLY.
DT_PREFIXONLY
Windows 2000: Draws only an underline at the position of the character following the ampersand (&) prefix character. Does not draw any character in the string.
DT_RIGHT
Aligns text to the right.
DT_RTLREADING
Displays text in right-to-left reading order for bi-directional text when a Hebrew or Arabic font is selected. The default reading order for all text is left-to-right.
DT_SINGLELINE
Displays text on a single line only. Carriage returns and line feeds do not break the line.
DT_TABSTOP
Sets tab stops. Bits 15 ? (high-order byte of the low-order word) of the Format parameter specify the number of characters for each tab. The default number of characters per tab is eight. The DT_CALCRECT, DT_EXTERNALLEADING, DT_INTERNAL, DT_NOCLIP, and DT_NOPREFIX values cannot be used with the DT_TABSTOP value.
DT_TOP
Top-justifies text (single line only).
DT_VCENTER
Centers text vertically (single line only).
DT_WORDBREAK
Breaks words. Lines are automatically broken between words if a word would extend past the edge of the rectangle specified by the pRect parameter. A carriage return/line feed sequence also breaks the line.
DT_WORD_ELLIPSIS
Truncates text that does not fit in the rectangle and adds ellipses.
Color
[in] Color of the text. For more information, see D3DCOLOR.

Return Value

If the function succeeds, the return value is the height of the text in logical units. If DT_VCENTER or DT_BOTTOM is specified, the return value is the offset from lpRect->top to the bottom of the drawn text.

If the function fails, the return value is zero.



Remarks

This function supports both ANSI and Unicode strings.

This method must be called inside a IDirect3DDevice9::BeginScene/IDirect3DDevice9::EndScene block.

Unless the DT_NOCLIP format is used, this method clips the text so that it does not appear outside the specified rectangle. All formatting is assumed to have multiple lines unless the DT_SINGLELINE format is specified.

If the selected font is too large for the rectangle, this method does not attempt to substitute a smaller font.

This method method supports only fonts whose escapement and orientation are both zero.



© 2002 Microsoft Corporation. All rights reserved.