CSize GetTextExtent( const CString& str ) const;
这个能返回字符串的大小
compute the width and height of a line of text using the current font to determine the dimensions.
BOOL GetTextMetrics( LPTEXTMETRIC lpMetrics ) const;
这个可以得到当前字体的高度,平均宽度等信息
Retrieves the metrics for the current font using the attribute device context.
说明LPTEXTMETRIC:
typedef struct tagTEXTMETRIC {
LONG tmHeight; //字体高度
LONG tmAscent; //基线以上的字体高度
LONG tmDescent; //基线以下的字体高度
LONG tmInternalLeading;
LONG tmExternalLeading;
LONG tmAveCharWidth; //字体的平均宽度
LONG tmMaxCharWidth;
LONG tmWeight;
LONG tmOverhang;
LONG tmDigitizedAspectX;
LONG tmDigitizedAspectY;
TCHAR tmFirstChar;
TCHAR tmLastChar;
TCHAR tmDefaultChar;
TCHAR tmBreakChar;
BYTE tmItalic;
BYTE tmUnderlined;
BYTE tmStruckOut;
BYTE tmPitchAndFamily;
BYTE tmCharSet;
} TEXTMETRIC, *PTEXTMETRIC;