首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

编程 兑现选择一种特定的字体

2012-09-15 
编程 实现选择一种特定的字体编程 实现选择一种特定的字体 像字体框那种效果 可是我只想要其中的几种 比如

编程 实现选择一种特定的字体
编程 实现选择一种特定的字体 像字体框那种效果 可是我只想要其中的几种 比如宋体 和华文隶书
 该怎么实现啊? 急死了。。。

[解决办法]
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT)); // clear out structure.
lf.lfHeight = 120; // request a 12-pixel-height font
strcpy(lf.lfFaceName, "Arial"); // request a face name "Arial".

CClientDC dc(this);

CFont font;
VERIFY(font.CreatePointFontIndirect(&lf, &dc));

// Do something with the font just created...
CFont* def_font = dc.SelectObject(&font);
dc.TextOut(5, 5, "Hello", 5);
dc.SelectObject(def_font);

// Done with the font. Delete the font object.
font.DeleteObject();

[解决办法]
EnumFonts枚举系统字体,加入ComboBox就是一个字体框效果了.
当然了,如果自绘一下ComboBox就更完美了.






热点排行