DrawText()到底能不能输出啊??? 最后一个参数好像是一个“格式”,用哪种格式可以输出??? 最好能详细写写。谢了。

解决方案 »

  1.   

    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. int DrawText(
      HDC hDC,          // handle to DC
      LPCTSTR lpString, // text to draw
      int nCount,       // text length
      LPRECT lpRect,    // formatting dimensions
      UINT uFormat      // text-drawing options
    );
      

  2.   

    dc->DrawText("测试",CRect(100,100,200,300),DT_SINGLELINE|DT_LEFT|DT_VCENTER)
      

  3.   

    最后参数格式可以是以下的组合
    DT_BOTTOM   Specifies bottom-justified text. 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, DrawText will use the width of the rectangle pointed to by lpRect and extend the base of the rectangle to bound the last line of text. If there is only one line of text, DrawText will modify 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_CENTER   Centers text horizontally.
    DT_END_ELLIPSIS or DT_PATH_ELLIPSIS   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.
    DT_EXPANDTABS   Expands tab characters. The default number of characters per tab is eight.
    DT_EXTERNALLEADING   Includes the font’s 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   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–linefeed