网站首页  词典首页

请输入您要查询的函数:

 

术语 drawtext
释义 DrawText
语法:
int DrawText(
__in HDC hDC,
__inout LPCTSTR lpchText,
__in int nCount,
__inout LPRECT lpRect,
__in UINT uFormat
);
DrawText函数
DrawText函数绘制的格式在指定的矩形的文本。它的格式文本按照指定的方法(扩展卡,证明字符,打破线,等等)。
要指定其他格式,请使用DrawTextEx功能。
参数
hDC [in]
一个句柄,设备上下文。
lpchText [ in , out ]
一个字符串,指定文本指针要绘制。如果nCount参数为-1,字符串必须是空终止。
如果uFormat包括DT_MODIFYSTRING,功能可以增加额外的多达4个字符,此字符串。缓冲区包含字符串应该足够大,以容纳这些额外的字符。
nCount [in]
的长度,以字符的字符串。如果nCount为-1,则lpchText参数假定为一个空指针结尾的字符串和DrawText字符数计算自动。
lpRect [ in , out ]
一个RECT结构,它包含矩形(在逻辑坐标),其中的文本被格式化的指针。
uFormat [in]
的格式文本的方法。此参数可以是一个或多个下列值。
ValueMeaning
DT_BOTTOMJustifies到矩形的底部的文本。此值仅用于与DT_SINGLELINE价值。
DT_CALCRECTDetermines的宽度和高度的矩形。如果多行文本,DrawText使用矩形的宽度指出,由lpRect参数和扩展了矩形基础的约束文本的最后一行。如果词是最大的,比矩形宽,宽度扩大。如果文本比矩形的宽度少,宽度减少。如果只有一行文本,DrawText修改矩形的右侧,以便它在边界线的最后一个字符。无论是哪种情况,DrawText返回格式化文本的高度,但没有绘制文本。
DT_CENTERCenters文字Level的矩形。
DT_EDITCONTROLDuplicates的文本显示多行编辑控件的特点。具体来说,平均字符宽度的计算方法相同的方式,作为一个编辑控制,该函数不显示部分可见的最后一行。
DT_END_ELLIPSISFor显示的文本,如果字符串的结束并不适合在矩形,它被截断,椭圆形补充。如果一个词不是在字符串的结尾的话,将是不椭圆截断超出矩形范围。
该字符串不会修改,除非DT_MODIFYSTRING标志被指定。
比较DT_PATH_ELLIPSIS和DT_WORD_ELLIPSIS。
DT_EXPANDTABSExpands制表符。每个制表符的默认数量为8。该DT_WORD_ELLIPSIS,DT_PATH_ELLIPSIS和DT_END_ELLIPSIS值不能用于与DT_EXPANDTABS价值。
DT_EXTERNALLEADINGIncludes字体外部领导的高度一致。通常情况下,外部的领导是不包括在文本行的高度。
DT_HIDEPREFIXIgnores的符号在文本(&)前缀字符。这封信后面将不强调,但其他记忆前缀字符仍在处理中。
例如:
输入字符串:“急症年&D”类
正常:“小宝及d”
DT_HIDEPREFIX:“小宝及d”
比较DT_NOPREFIX和DT_PREFIXONLY。
DT_INTERNALUses系统字体来计算文本数据。
DT_LEFTAligns文本左。
DT_MODIFYSTRINGModifies指定的字符串匹配显示的文本。此值不会,除非DT_END_ELLIPSIS或DT_PATH_ELLIPSIS指定的效果。
DT_NOCLIPDraws未经剪辑。 DrawText是稍快,使用时DT_NOCLIP。
DT_NOFULLWIDTHCHARBREAKPrevents在DBCS中换行符(双宽字符的字符串),因此该行打破规则相当于半角字符串。例如,这可以用于在韩国的窗口,为更多的图标标签的可读性。此值,除非DT_WORDBREAK没有指定作用。
DT_NOPREFIXTurns过前缀字符的处理。通常情况下,DrawText解释助记前缀字符与作为一项指令,强调后面的字符,并助记前缀字符&作为一项指令,打印单个&。通过指定DT_NOPREFIX,这种处理是关闭的。例如,
例如:
输入字符串:“急症年&D”类
正常:“小宝及d”
DT_NOPREFIX:“急症年&D”类
比较DT_HIDEPREFIX和DT_PREFIXONLY。
DT_PATH_ELLIPSISFor显示的文本,替换在字符串中的字符椭圆以确保测试结果在指定的矩形适合。如果该字符串包含反斜杠(\\)字符,DT_PATH_ELLIPSIS尽可能保留的文本可能在最后反斜杠。
该字符串不会修改,除非DT_MODIFYSTRING标志被指定。
比较DT_END_ELLIPSIS和DT_WORD_ELLIPSIS。
DT_PREFIXONLYDraws强调只有在以下的符(&)前缀字符的字符位置。不提请字符串中的任何其他字符。例如,
例如:
输入字符串:“急症年&D”类?
正常:“小宝及d”
DT_PREFIXONLY:“_”
比较DT_HIDEPREFIX和DT_NOPREFIX。
DT_RIGHTAligns文字的权利。
在从右到DT_RTLREADINGLayout左的阅读顺序为双向文本的字体时,将选定的HDC是希伯来文或阿拉伯文字体。所有文本的默认阅读顺序是从左向右的。
DT_SINGLELINEDisplays文本在一行只。回车符和换行符不断行。
DT_TABSTOPSets制表位。位15-8(高序的低位字字节的uFormat参数)指定的字符每个标签号码。每个制表符的默认数量为8。该DT_CALCRECT,DT_EXTERNALLEADING,DT_INTERNAL,DT_NOCLIP和DT_NOPREFIX值不能用于与DT_TABSTOP价值。
DT_TOPJustifies到矩形的顶部的文本。
DT_VCENTERCenters text vertically.此值仅用于与DT_SINGLELINE价值。
DT_WORDBREAKBreaks话。线条自动断字与字之间,如果一个字将扩大过去由lpRect参数指定的矩形的边缘。 A carriage return-line feed sequence also breaks the line.
如果这是没有指定,输出是在一行。
DT_WORD_ELLIPSISTruncates任何词,并不适合在矩形,并增加了省略号。
比较DT_END_ELLIPSIS和DT_PATH_ELLIPSIS。
返回值
如果函数成功,返回值是在逻辑单元文本的高度。如果DT_VCENTER或DT_BOTTOM被指定,返回值是由lpRect失调“的顶部绘制的文本的下
如果函数失败,返回值是零。
备注
该DrawText函数使用设备上下文选定的字体,文字颜色和背景颜色绘制文本。除非DT_NOCLIP格式使用,DrawText剪辑的文本,以便它不会出现超出规定的矩形。请注意,具有重大悬文本可能被剪辑,例如,一个初步的“W”的文本字符串或文字是斜体。所有格式假定有多个行,除非DT_SINGLELINE格式指定。
如果所选的字体过于指定的矩形大,DrawText函数并不试图取代一个较小的字体。
该设备上下文文本对齐方式必须包括TA_LEFT,TA_TOP和TA_NOUPDATECP标志。
实例
有关示例,请参见“显示键盘输入”的使用键盘输入。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinuser.h(头文件:winuser.h)
LibraryUser32.lib
DLLUser32.dll
Unicode和ANSI namesDrawTextW(Unicode)和DrawTextA(ANSI)的
参见
字体和文字概述
字体和文本函数
DrawTextEx
GrayString
TabbedTextOut
TextOut
RECT
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月11日
==英文原文==DrawText Function
The DrawText function draws formatted text in the specified rectangle. It formats the text according to the specified method (expanding tabs, justifying characters, breaking lines, and so forth).
To specify additional formatting options, use the DrawTextEx function.
Syntax
int DrawText(
__in HDC hDC,
__inout LPCTSTR lpchText,
__in int nCount,
__inout LPRECT lpRect,
__in UINT uFormat
);
Parameters
hDC [in]
A handle to the device context.
lpchText [in, out]
A pointer to the string that specifies the text to be drawn. If the nCount parameter is -1, the string must be null-terminated.
If uFormat 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.
nCount [in]
The length, in characters, of the string. If nCount is -1, then the lpchText parameter is assumed to be a pointer to a null-terminated string and DrawText computes the character count automatically.
lpRect [in, out]
A pointer to a RECT structure that contains the rectangle (in logical coordinates) in which the text is to be formatted.
uFormat [in]
The method of formatting the text. This parameter can be one or more of the following values.
ValueMeaning
DT_BOTTOMJustifies the text to the bottom of the rectangle. This value is used only with the DT_SINGLELINE value.
DT_CALCRECTDetermines the width and height of the rectangle. If there are multiple lines of text, DrawText uses the width of the rectangle pointed to by the lpRect parameter and extends the base of the rectangle to bound the last line of text. If the largest word is wider than the rectangle, the width is expanded. If the text is less than the width of the rectangle, the width is reduced. If there is only one line of text, DrawText modifies the right side of the rectangle so that it bounds the last character in the line. In either case, DrawText returns the height of the formatted text but does not draw the text.
DT_CENTERCenters text horizontally in the rectangle.
DT_EDITCONTROLDuplicates 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_ELLIPSISFor displayed text, if the end of a string does not fit in the rectangle, it is truncated and ellipses are added. If a word that is not at the end of the string goes beyond the limits of the rectangle, it is truncated without ellipses.
The string is not modified unless the DT_MODIFYSTRING flag is specified.
Compare with DT_PATH_ELLIPSIS and DT_WORD_ELLIPSIS.
DT_EXPANDTABSExpands 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_EXTERNALLEADINGIncludes the font external leading in line height. Normally, external leading is not included in the height of a line of text.
DT_HIDEPREFIXIgnores the ampersand (&) prefix character in the text. The letter that follows will not be underlined, but other mnemonic-prefix characters are still processed.
Example:
input string: "A&bc&&d"
normal: "Abc&d"
DT_HIDEPREFIX: "Abc&d"
Compare with DT_NOPREFIX and DT_PREFIXONLY.
DT_INTERNALUses the system font to calculate text metrics.
DT_LEFTAligns text to the left.
DT_MODIFYSTRINGModifies the specified string to match the displayed text. This value has no effect unless DT_END_ELLIPSIS or DT_PATH_ELLIPSIS is specified.
DT_NOCLIPDraws without clipping. DrawText is somewhat faster when DT_NOCLIP is used.
DT_NOFULLWIDTHCHARBREAKPrevents a line break at a DBCS (double-wide character string), so that the line breaking rule is equivalent to SBCS strings. For example, this can be used in Korean windows, for more readability of icon labels. This value has no effect unless DT_WORDBREAK is specified.
DT_NOPREFIXTurns off processing of prefix characters. Normally, 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. For example,
Example:
input string: "A&bc&&d"
normal: "Abc&d"
DT_NOPREFIX: "A&bc&&d"
Compare with DT_HIDEPREFIX and DT_PREFIXONLY.
DT_PATH_ELLIPSISFor displayed text, replaces characters in the middle of the string with ellipses so that the result fits in the specified rectangle. If the string contains backslash (\\) characters, DT_PATH_ELLIPSIS preserves as much as possible of the text after the last backslash.
The string is not modified unless the DT_MODIFYSTRING flag is specified.
Compare with DT_END_ELLIPSIS and DT_WORD_ELLIPSIS.
DT_PREFIXONLYDraws only an underline at the position of the character following the ampersand (&) prefix character. Does not draw any other characters in the string. For example,
Example:
input string: "A&bc&&d"n
normal: "Abc&d"
DT_PREFIXONLY: " _ "
Compare with DT_HIDEPREFIX and DT_NOPREFIX.
DT_RIGHTAligns text to the right.
DT_RTLREADINGLayout 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.
DT_SINGLELINEDisplays text on a single line only. Carriage returns and line feeds do not break the line.
DT_TABSTOPSets tab stops. Bits 15-8 (high-order byte of the low-order word) of the uFormat 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_TOPJustifies the text to the top of the rectangle.
DT_VCENTERCenters text vertically. This value is used only with the DT_SINGLELINE value.
DT_WORDBREAKBreaks words. Lines are automatically broken between words if a word would extend past the edge of the rectangle specified by the lpRect parameter. A carriage return-line feed sequence also breaks the line.
If this is not specified, output is on one line.
DT_WORD_ELLIPSISTruncates any word that does not fit in the rectangle and adds ellipses.
Compare with DT_END_ELLIPSIS and DT_PATH_ELLIPSIS.

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
The DrawText function uses the device context's selected font, text color, and background color to draw the text. Unless the DT_NOCLIP format is used, DrawText clips the text so that it does not appear outside the specified rectangle. Note that text with significant overhang may be clipped, for example, an initial "W" in the text string or text that is in italics. All formatting is assumed to have multiple lines unless the DT_SINGLELINE format is specified.
If the selected font is too large for the specified rectangle, the DrawText function does not attempt to substitute a smaller font.
The text alignment mode for the device context must include the TA_LEFT, TA_TOP, and TA_NOUPDATECP flags.
Examples
For an example, see "Displaying Keyboard Input" in Using Keyboard Input .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinuser.h (include Windows.h)
LibraryUser32.lib
DLLUser32.dll
Unicode and ANSI namesDrawTextW (Unicode) and DrawTextA (ANSI)
See Also
Fonts and Text Overview
Font and Text Functions
DrawTextEx
GrayString
TabbedTextOut
TextOut
RECT
Send comments about this topic to Microsoft
Build date: 7/11/2009
==原始网址==http://msdn.microsoft.com/en-us/library/dd162498(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:25:07