开发者社区 问答 正文

如何读取用户选择的字体,是在mfc中

已解决

CFontDialog dlg;
if(dlg.DoModal() == IDOK)
下面怎么设置CEdit1

展开
收起
WM云建站 2016-02-17 21:56:43 2123 分享 版权
1 条回答
写回答
取消 提交回答
  • 阿里云论坛版主,QQ 1978638808
    采纳回答
      GetDlgItem(IDC_EDIT_SEND)->GetFont()->GetLogFont(&lf);
     CFontDialog dlg(&lf);        //初始化字体对话框中的字体信息
     if(IDOK==dlg.DoModal())
     {
      if(m_wordstyle.m_hObject)
       m_wordstyle.DeleteObject();
      LOGFONT logfont;
      dlg.GetCurrentFont(&logfont);  //获取选择的字体信息
      m_wordstyle.CreateFontIndirect(&logfont);   //m_wordstyle为类成员,CFont类型
      GetDlgItem(IDC_EDIT_SEND)->SetFont(&m_wordstyle);
      Invalidate();
    2019-07-17 18:29:14
    赞同 展开评论
问答地址: