使用对话框的惯例:
if(fontdlg.DoModal()==IDOK)
{
    m_size  = fontdlg.GetSize();
    m_style = fontdlg.GetStyle();
    ......
}
原因,调玩DoModal()函数对话框已经Destroy掉了,那么所有的选择呢,自己分析一下。

解决方案 »

  1.   

    CFontDialog 有一个重要的数据成员
    m_cf一个用于定制CFontDialog对象的结构只有以下成员函数:
    DoModal显示对话框并使用户选择
    GetCurrentFont获取当前选定字体的名字
    GetFaceName返回选择字体的字样名称
    GetStyleName返回选择字体的风格名称
    GetSize返回选择字体的点大小
    GetColor返回选择字体的颜色
    GetWeight返回选择字体的磅数
    IsStrikeOut判断字体是否是突出
    IsUnDerline判断字体是否是下划线
    IsBold判断字体是否是黑体
    IsItalic判断字体是否是斜体
      

  2.   

    通常使用m_cf结构
    例:CFontDialog dlg;
    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(5, 5, "Hello", 5);
       dc.SelectObject(def_font);   // Done with the font. Delete the font object.
       font.DeleteObject();
    }