WinCE 中写字的函数

Platform Builder for Microsoft Windows CE 5.0  

DrawText

This function draws formatted text in the specified rectangle. DrawText formats the text according to the specified format method.

int DrawText(
  HDC hDC, 
  LPCTSTR lpString, 
  int nCount, 
  LPRECT lpRect, 
  UNIT uFormat
);
Parameters
hDC
[in] Handle to the device context.
lpString
[in] Long pointer to the string that you want to draw. If the nCount parameter is –1, you must specify a null-terminated string.
nCount
[in] Integer that specifies the number of characters in the string. If nCount is –1, DrawText assumes that the lpString parameter is a pointer to a null-terminated string and computes the character count automatically.
lpRect
[in] Long pointer to a RECT structure that contains the rectangle, in logical coordinates, in which you want to format the text.
uFormat
[in] Unsigned integer that specifies the method of formatting the text. The following table shows the possible values that you can combine to create a value for this parameter.
ValueDescription
DT_BOTTOMJustifies the text to the bottom of the rectangle. You must combine this value with DT_SINGLELINE.
DT_CALCRECTDetermines the width and height of the rectangle. If the rectangle includes 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 rectangle includes 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.

Before calling DrawText, an application must set the right and bottom members of the RECT structure pointed to by lpRect. These members are updated with the call to DrawText.

DT_CENTERCenters text horizontally in the rectangle.
DT_END_ELLIPSISTruncates a text string that is wider than the display rectangle and adds an ellipsis to indicate the truncation.
DT_EXPANDTABSExpands tab characters. The default number of characters per tab is eight.
DT_INTERNALUses the system font to calculate text metrics.
DT_LEFTAligns text to the left.
DT_NOCLIPDraws without clipping. DrawText is somewhat faster when DT_NOCLIP is used.
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.
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 linefeeds do not break the line.
DT_TABSTOPSets tab stops. Bits 8–15, which form the 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. You cannot use the DT_CALCRECT, DT_EXTERNALLEADING, DT_INTERNAL, DT_NOCLIP, and DT_NOPREFIX values with the DT_TABSTOP value.
DT_TOPTop-justifies text. You must combine this value with DT_SINGLELINE.
DT_VCENTERCenters text vertically. You must combine this value with DT_SINGLELINE.
DT_WORD_ELLIPSISTruncates any word that does not fit in the display rectangle and adds an ellipsis.
DT_WORDBREAKBreaks words. DrawText automatically breaks lines between words if a word would extend past the edge of the rectangle specified by the lpRect parameter. A carriage return-linefeed sequence also breaks the line.
Return Values

The height of the text indicates success. Zero indicates failure. To get extended error information, call GetLastError .

Remarks

The DrawText function uses the selected font, text color, and background color for the device context to draw the text. Unless you specify the DT_NOCLIP value, DrawText clips the text so that it does not appear outside the specified rectangle. DrawText assumes that all formatting has multiple lines unless you specify the DT_SINGLELINE format.

If the selected font is too large for the specified rectangle, the DrawText function does not attempt to substitute a smaller font.

For Windows CE 2.10 and later, line breaking is supported for the Chinese, Korean, and Japanese languages.

Requirements

OS Versions: Windows CE 1.0 and later.
Header: Windows.h.
Link Library: Coredll.lib.

See Also

ExtTextOut | RECT


 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值