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;
本文介绍如何使用CSizeGetTextExtent函数来获取字符串的尺寸,并通过GetTextMetrics函数来检索当前字体的各种度量信息,包括字体的高度、平均宽度等。
6251

被折叠的 条评论
为什么被折叠?



