GetTextMetrics,该函数把程序当前的字体信息,存放到TEXTMETRIC(即MSDN原文中的specified buffer)中。
GetTextMetrics,该函数把程序当前的字体信息,存放到TEXTMETRIC(即MSDN原文中的specified buffer)中。
该函数把程序当前的字体信息,存放到TEXTMETRIC(即MSDN原文中的specified buffer)中。
函数原型:
BOOL GetTextMetrics(HDC hdc, LPTEXTMETRIC lptm);
hdc:设备环境句柄。
lptm:指向结构TEXTMETRIC的指针,该结构用于获得字体信息。
返回值:
如果函数调用成功,返回值非零,如果函数调用失败,返回值是0。
Windows NT2000XP:若想获得更多错误信息,请调用GetLastError函数。
Windows 95/98/Me:对于这样的版本,需要去下载Microsoft layer提供的MSLU(详见:2008年12月的MSDN).
Windows NT:3.1及以上版本;Windows:95及以上版本;Windows CE:
1.0及以上版本;
头文件:wingdi.h;
库文件:gdi32.lib;
Unicode:在Windows NT环境下实现为Unicode和ANSI两种版本。
包含的头文件:afxwin.h
示例:
BOOL GetTextMetrics(
LPTEXTMETRIC lpMetrics
) const;
参数结构为
TEXTMETRIC Structure
The TEXTMETRIC structure has the following form:
typedef struct tagTEXTMETRIC {
int tmHeight; int tmAscent;
int tmDescent;
int tmInternalLeading;
int tmExternalLeading;
int tmAveCharWidth;
int tmMaxCharWidth;
int tmWeight;
BYTE tmItalic;
BYTE tmUnderlined;
BYTE tmStruckOut;
BYTE tmFirstChar;
BYTE tmLastChar;
BYTE tmDefaultChar;
BYTE tmBreakChar;
BYTE tmPitchAndFamily;
BYTE tmCharSet;
int tmOverhang;
int tmDigitizedAspectX;
int tmDigitizedAspectY;
} TEXTMETRIC;
TEXTMETRIC结构包含了关于字体的基本物理信息。所有的大小都是以逻辑单位给出的,也就是说,它们依赖于显示设备的当前图形编码模式。
有关此结构更完整的信息,请查阅Win32 SDK文档中的TEXTMETRIC。