设置字体,建议在WM_CREATE消息处理中进行设置
设置系统字体有多种方法
方法一:CreateFont函数设置每一个参数
HFONT hFont = CreateFont(80,0,0,0,0,0,0,0,DEFAULT_CHARSET,0,0,0,0,TEXT("新宋体"));
SelectObject(hdc,hFont);
CreateFont函数的定义
INGDIAPI HFONT WINAPI
CreateFontW(
__in int cHeight, //设置字体高度
__in int cWidth, //宽度操作系统可以更具高度进行自动计算,可以直接设置为0
__in int cEscapement,
__in int cOrientation,
__in int cWeight,
__in DWORD bItalic,
__in DWORD bUnderline,
__in DWORD bStrikeOut,
__in DWORD iCharSet, //字符集可以使用DEFAULT_CHARSET或是OEM_CHARSET
__in DWORD iOutPrecision,
__in DWORD iClipPrecision,
__in DWORD iQuality, //点阵字体才会有用,现在用的字符集都用不到
__in DWORD iPitchAndFamily, //字间距
__in_opt LPCWSTR pszFaceName //字体名称
);
#ifdef UNICODE
#define CreateFont CreateFontW
#else
#define CreateFont CreateFontA
#endif // !UNICODE
方法二:CreateFontIndirect函数使用一个LOGFONT结构本进行设置
HFONT hFont;
LOGFONT lf;
lf.lfCharSet = OE