DrawText显示文字的时候可以用DT_WORDBREAK自动换行,但换行后各行之间的行间距如何设置?
谢谢。

解决方案 »

  1.   

    int DrawText(    HDC hDC, // handle to device context 
        LPCTSTR lpString, // pointer to string to draw 
        int nCount, // string length, in characters 
        LPRECT lpRect, // pointer to structure with formatting dimensions  
        UINT uFormat  // text-drawing flags 
       );
    关键是设置lpRect的范围大小来决定。
      

  2.   

    同意 csdn_lee() ,和你创建Font时设置的字高lfHeight有关,参考CreateFont
      

  3.   

    msdn platform/gdi/font里面看一下,有详细介绍
      

  4.   

    刚刚调试了一下,发现与Rect无关,应该是与字体高度有关:如下:
            AnsiString S;
            TRect TheRect;
            TheRect = Rect(10,10,100,950);
            S="请您对您的言行负责,并遵守中华人民共和国有关法律、法规,尊重网上道德。" ;
    //改变下面的数值将会使行距变化
            Canvas->Font->Height=80;
            DrawText(Form1->Canvas->Handle,S.c_str(),S.Length(),&TheRect,DT_WORDBREAK);
    ***********************************
    但我们应该知道,关键不是改变字体,而应该是在字体不变的情况下改变间距啊!
    正在调试中....:P
      

  5.   

    字体大小可以用逻辑字体结构来定义 字体的间距分内间距和外间距 。你去查查msdn上关于CFont 我在网吧没发查
      

  6.   

    String Widths and HeightsIn addition to retrieving character-width data for individual characters, applications also need to compute the width and height of entire strings. Two functions retrieve string-width and height measurements: GetTextExtentPoint32, and GetTabbedTextExtent. If the string does not contain tab characters, an application can use the GetTextExtentPoint32 function to retrieve the width and height of a specified string. If the string contains tab characters, an application should call the GetTabbedTextExtent function. Applications ca use the GetTextExtentExPoint function for word-wrapping operations. This function returns the number of characters from a specified string that fit within a specified space. Font Ascenders and Descenders
    Some applications determine the line spacing between text lines of different sizes by using a font's maximum ascender and descender. An application can retrieve these values by calling the GetTextMetrics function and then checking the tmAscent and tmDescent members of the TEXTMETRIC. The maximum ascent and descent are different from the typographic ascent and descent. In TrueType and OpenType fonts, the typographic ascent and descent are typically the top of the f glyph and bottom of the g glyph. An application can retrieve the typographic ascender and descender for a TrueType or OpenType font by calling the GetOutlineTextMetrics function and checking the values in the otmMacAscent and otmMacDescent members of the OUTLINETEXTMETRIC structure. The following figure shows the difference between the vertical text metric values returned in the NEWTEXTMETRIC and OUTLINETEXTMETRIC structures. (The names beginning with otm are members of the OUTLINETEXTMETRIC structure.) Font Dimensions
    An application can retrieve the physical dimensions of a TrueType or OpenType font by calling the GetOutlineTextMetrics function. An application can retrieve the physical dimensions of any other font by calling the GetTextMetrics function. To determine the dimensions of an output device, an application can call the GetDeviceCaps function. GetDeviceCaps returns both physical and logical dimensions. A logical inch is a measure the system uses to present legible fonts on the screen and is approximately 30 to 40 percent larger than a physical inch. The use of logical inches precludes an exact match between the output of the screen and printer. Developers should be aware that the text on a screen is not simply a scaled version of the text that will appear on the page, particularly if graphics are incorporated into the text. =================
    MSDN / platform sdk/graphics/windows GDI/fonts and texts/about text output/formating text/String Widths and Heights
    里面还有图解,够详细了吧,总不能连代码也帮你写了吧