please dont rip this site Prev Next

DrawTextEx info  Overview  Group

The DrawTextEx function draws formatted text in the specified rectangle.

int DrawTextEx(

    HDC hdc,

// handle to device context

    LPTSTR lpchText,

// pointer to string to draw

    int cchText,

// length of string to draw

    LPRECT lprc,

// pointer to rectangle coordinates

    UINT dwDTFormat,

// formatting options


// pointer to structure for more options



Identifies the device context to draw in.
Points to the string to draw. The string must be null-terminated if the cchText parameter is -1.
Specifies the length, in characters, of the string specified by the lpchText parameter. If the string is null-terminated, this parameter can be -1 to calculate the length.
Points to a RECT structure that contains the rectangle, in logical coordinates, in which the text is to be formatted.
Specifies formatting options. This parameter can be one or more of these values:




Justifies the text to the bottom of the rectangle. This value must be combined with DT_SINGLELINE.


Determines the width and height of the rectangle. If there are multiple lines of text, DrawTextEx uses the width of the rectangle pointed to by the lprc parameter and extends the base of the rectangle to bound the last line of text. If there is only one line of text, DrawTextEx modifies the right side of the rectangle so that it bounds the last character in the line. In either case, DrawTextEx returns the height of the formatted text, but does not draw the text.


Centers text horizontally in the rectangle.


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.


Replaces part of the given string with ellipses, if necessary, so that the result fits in the specified rectangle. The given string is not modified unless the DT_MODIFYSTRING flag is specified.

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


Expands tab characters. The default number of characters per tab is eight.


Includes the font external leading in line height. Normally, external leading is not included in the height of a line of text.


Aligns text to the left.


Modifies the given string to match the displayed text. This flag has no effect unless the DT_END_ELLIPSIS or DT_PATH_ELLIPSIS flag is specified.


Draws without clipping. DrawTextEx is somewhat faster when DT_NOCLIP is used.


Turns off processing of prefix characters. Normally, DrawTextEx interprets the ampersand (&) mnemonic-prefix character as a directive to underscore the character that follows, and the double ampersand (&&) mnemonic-prefix characters as a directive to print a single ampersand. By specifying DT_NOPREFIX, this processing is turned off.


Aligns text to the right.


Layout in right to left reading order for bi-directional text when the font selected into the hdc is a Hebrew or Arabic font. The default reading order for all text is left to right.


Displays text on a single line only. Carriage returns and linefeeds do not break the line.


Sets tab stops. The DRAWTEXTPARAMS structure pointed to by the lpDTParams parameter specifies the number of average character widths per tab stop.


Top justifies text (single line only).


Centers text vertically (single line only).


Breaks words. Lines are automatically broken between words if a word extends past the edge of the rectangle specified by the lprc parameter. A carriage return-linefeed sequence also breaks the line.

Points to a DRAWTEXTPARAMS structure that specifies additional formatting options. This parameter can be NULL.

Return Values

If the function succeeds, the return value is the text height.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

See Also


file: /Techref/os/win/api/win32/func/src/f18_9.htm, 9KB, , updated: 2000/4/7 12:19, local time: 2024/7/20 08:28,

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF=""> DrawTextEx</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

  PICList 2024 contributors:
o List host: MIT, Site host, Top posters @none found
- Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.

Welcome to!