有高人知道DrawText()后的高度吗?
谢谢了.

解决方案 »

  1.   

    CSize GetTextExtent(
       LPCTSTR lpszString,
       int nCount 
    ) const;
      

  2.   

    CFont font;
    VERIFY(font.CreateFont(
       12,                        // 你在画之前将这个值记录下来不就行了
       0,                         // nWidth
       0,                         // nEscapement
       0,                         // nOrientation
       FW_NORMAL,                 // nWeight
       FALSE,                     // bItalic
       FALSE,                     // bUnderline
       0,                         // cStrikeOut
       ANSI_CHARSET,              // nCharSet
       OUT_DEFAULT_PRECIS,        // nOutPrecision
       CLIP_DEFAULT_PRECIS,       // nClipPrecision
       DEFAULT_QUALITY,           // nQuality
       DEFAULT_PITCH | FF_SWISS,  // nPitchAndFamily
       "Arial"));
      

  3.   

    CDC *pDC;
    TEXTMETRIC tm;
    CString str;
    pDC->GetTextMetrics(&tm);
    str.Format("高度为:%d",tm.tmHeight);
    MessageBox(str);
      

  4.   

    DrawText的返回值就是你所要的高度,参见MSDN。
      

  5.   

    使用 DT_CALCRECT 格式可以返回高度
      

  6.   

    mfc用CDC::GetTextExtent 
    CSize GetTextExtent(
       LPCTSTR lpszString,
       int nCount 
    ) const;
    CSize GetTextExtent(
       const CString& str 
    ) const;SDK用GetTextExtentPoint32
    BOOL GetTextExtentPoint32(
      HDC hdc,           // handle to DC
      LPCTSTR lpString,  // text string
      int cbString,      // characters in string
      LPSIZE lpSize      // string size
    );
      

  7.   

    果然
    Return Value
    The height of the text if the function is successful.