last backslash.
DT_EXPANDTABS Expands tab characters. The default number of characters per tab is eight.
DT_EXTERNALLEADING Includes the font 抯 external leading in the line height. Normally,
external leading is not included in the height of a line of text.
DT_LEFT 左对齐 Aligns text flush-left.
DT_MODIFYSTRING 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.
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.
DT_NOCLIP Draws without clipping. DrawText is somewhat faster when DT_NOCLIP is
used.
DT_NOPREFIX 禁止使用&前缀 Turns off processing of prefix characters. Normally,
DrawText interprets the ampersand (&) mnemonic-prefix character as a directive to underscore the
character that follows, and the two-ampersand (&&) mnemonic-prefix characters as a directive to
print a single ampersand. By specifying DT_NOPREFIX, this processing is turned off.
DT_PATH_ELLIPSIS
DT_RIGHT 右对齐 Aligns text flush-right.
DT_SINGLELINE 单行输出 Specifies single line only. Carriage returns and linefeeds do not
break the line.
DT_TABSTOP 设置 TAB 字符所占宽度 Sets tab stops. The high-order byte of nFormat is the
number of characters for each tab. The default number of characters per tab is eight.
DT_TOP 定部对齐 Specifies top-justified text (single line only).
DT_VCENTER 中部对齐 Specifies vertically centered text (single line only).
DT_WORDBREAK 每行只在单词间被折行 Specifies word-breaking. Lines are
automatically broken between words if a word would extend past the edge of the rectangle
specified by lpRect. A carriage return 杔 inefeed sequence will also break the line.
在输出文字时如果希望改变文字的颜色,你可以利用 CDC::SetTextColor( COLORREF
crColor )进行设置,如果你希望改变背景色就利用 CDC::SetBkColor( COLORREF crColor ),
很多时候你可能需要透明的背景色你可以利用 CDC::SetBkMode( int nBkMode )设置,可接
受的参数有
OPAQUE Background is filled with the current background color before the text, hatched
brush, or pen is drawn. This is the default background mode.
TRANSPARENT Background is not changed before drawing.
接下来讲讲如何创建字体,你可以创建的字体有两种:库存字体 CDC::CreateStockObject( int
nIndex )和自定义字体。
在创建非库存字体时需要填充一个 LOGFONT 结构并使用 CFont::CreateFontIndirect(const
LOGFONT* lpLogFont )(可以参考文章在同一系统中显示 GB 字符和 BIG5 字符),或使用
CFont::CreateFont( int nHeight, int nWidth, int nEscapement, int nOrientation, int nWeight,
BYTE bItalic, BYTE bUnderline, BYTE cStrikeOut, BYTE nCharSet, BYTE nOutPrecision,
BYTE nClipPrecision, BYTE nQuality, BYTE nPitchAndFamily, LPCTSTR lpszFacename )其中
的参数和 LOGFONT 中的分量有一定的对应关系。下面分别讲解参数的意义:
nHeight 字体高度(逻辑单位)等于零为缺省高度,否则取绝对值并和可用的字体高度进行
匹配。