Export (0) Print
Expand All

CFontDialog::m_cf 

A structure whose members store the characteristics of the dialog object.


CHOOSEFONT m_cf;

After constructing a CFontDialog object, you can use m_cf to modify various aspects of the dialog box before calling the DoModal member function. For more information on this structure, see CHOOSEFONT in the Platform SDK.

// The code fragment creates a font based on the information 
// we got from CFontDialog::m_cf variable.

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();
}

Community Additions

ADD
Show:
© 2014 Microsoft