void CMfcFontDlgDlg::OnBtnFont()
{
// Show the font dialog with all the default settings.
CFontDialog dlg;
dlg.DoModal();
} void CMfcFontDlgDlg::OnBtnFontSpecial()
{
// Show the font dialog with 12 point "Times New Roman" as the selected font.
LOGFONT lf;
memset(&lf, , sizeof(LOGFONT)); CClientDC dc(this);
lf.lfHeight = -MulDiv(, dc.GetDeviceCaps(LOGPIXELSY), );
strcpy(lf.lfFaceName, "Times New Roman"); CFontDialog dlg(&lf);
// The code fragment creates a font based on the information we got from CFontDialog::m_cf variable.
if (dlg.DoModal() == IDOK)
{
// Create the font using the selected font from CFontDialog.
LOGFONT lf;
memcpy(&lf, dlg.m_cf.lpLogFont, sizeof(LOGFONT)); CFont font;
VERIFY(font.CreateFontIndirect(&lf)); // Do something with the font just created...
CClientDC dc(this);
CFont* def_font = dc.SelectObject(&font);
dc.TextOut(, , "Hello", );
dc.SelectObject(def_font); // Done with the font. Delete the font object.
font.DeleteObject();
}
} void CMfcFontDlgDlg::OnBtnFontProperty()
{
// Get the characteristics
CFontDialog dlg;
if (dlg.DoModal() == IDOK)
{
// Get the characteristics of the currently selected font, if any.
LOGFONT lf;
dlg.GetCurrentFont(&lf);
TRACE("Face name of the selected font = %s\n", lf.lfFaceName);
// Get the face name of the selected font, if any.
CString facename = dlg.GetFaceName();
TRACE("Face name of the selected font = %s\n", facename);
// Get the style name of the selected font, if any.
CString stylename = dlg.GetStyleName();
TRACE("Style name of the selected font = %s\n", stylename);
// Get the size of the selected font, if any.
int size = dlg.GetSize();
TRACE("The size of the selected font = %d\n", size);
// Get the color of the selected font, if any.
COLORREF color = dlg.GetColor();
TRACE("Color of the selected font = %8x\n", color);
// Get the weight of the selected font, if any.
int weight = dlg.GetWeight();
TRACE("Weight of the selected font = %d\n", weight);
// Is the selected font displayed with strikeout?
BOOL strikeout = dlg.IsStrikeOut();
TRACE("Is the selected font displayed with strikeout? %d\n", strikeout);
// Is the selected font underlined?
BOOL underline = dlg.IsUnderline();
TRACE("Is the selected font underlined? %d\n", underline);
// Is the selected font bold?
BOOL bold = dlg.IsBold();
TRACE("Is the selected font bold? %d\n", bold);
// Is the selected font italic?
BOOL italic = dlg.IsItalic();
TRACE("Is the selected font italic? %d\n", italic);
}
}

最新文章

  1. Post方式打开新窗口
  2. Android 中shape的使用(圆角矩形)
  3. 使用USRP探索无线世界 Part 1:USRP从入门到追踪飞机飞行轨迹
  4. 导出DBF,并且提供下载 [转]
  5. jeecg的cq查询方式
  6. NOIP 2014 普及组 T3 螺旋矩阵
  7. vmware10中开启Intel VT-x
  8. JQuery图片滑动插件
  9. React系列(一):React入门
  10. chromium源码阅读--HTTP Cache
  11. 芝麻HTTP:Python爬虫实战之爬取糗事百科段子
  12. loadrunner迭代和并发的区别
  13. PRML读书笔记_绪论曲线拟合部分
  14. [转]分布式系统唯一ID生成方案汇总
  15. GTX1060 深度学习工具链
  16. 【Spring boot】第一个项目 Springboot + mysql + hibernate
  17. MySQL大数据高并发处理之-查询的优化
  18. Sublime Text 套件介紹:Pretty JSON
  19. SurfaceView和SurfaceHolder的基本用法
  20. 基于Vue、web3的以太坊项目开发及交易内幕初探 错误解决总结

热门文章

  1. 算法笔记_049:奇偶数排序(Java)
  2. std::shared_ptr 和 std::weak_ptr的用法以及引用计数的循环引用问题
  3. OTU_Network&calc_otu
  4. Linux的定时器
  5. 使用DotNetZip压缩与解压缩
  6. ClientViaBehavior行为
  7. jquery.cookie中的操作之与换肤
  8. 联想E440问题:点击鼠标时,弹出“无法连接synaptics定点装置驱动程序”错误
  9. Zip 压缩问题件,获取真实扩展名
  10. app store上传图片显示错误:未能创建 屏幕快照