共用方式為


CFontDialog::CFontDialog

Constructs a CFontDialog object.

CFontDialog(
   LPLOGFONT lplfInitial = NULL,
   DWORD dwFlags = CF_EFFECTS | CF_SCREENFONTS,
   CDC* pdcPrinter = NULL,
   CWnd* pParentWnd = NULL 
);
CFontDialog( 
   const CHARFORMAT& charformat, 
   DWORD dwFlags = CF_SCREENFONTS, 
   CDC* pdcPrinter = NULL, 
   CWnd* pParentWnd = NULL 
);

Parameters

  • lplfInitial
    A pointer to a LOGFONT data structure that allows you to set some of the font's characteristics.

  • charFormat
    A pointer to a CHARFORMAT data structure that allows you to set some of the font's characteristics in a rich edit control.

  • dwFlags
    Specifies one or more choose-font flags. One or more preset values can be combined using the bitwise OR operator. If you modify the m_cf.Flags structure member, be sure to use a bitwise OR operator in your changes to keep the default behavior intact. For details on each of these flags, see the description of the CHOOSEFONT structure in the Windows SDK.

  • pdcPrinter
    A pointer to a printer-device context. If supplied, this parameter points to a printer-device context for the printer on which the fonts are to be selected.

  • pParentWnd
    A pointer to the font dialog box's parent or owner window.

Remarks

Note that the constructor automatically fills in the members of the CHOOSEFONT structure. You should only change these if you want a font dialog different than the default.

注意

The first version of this function only exists when there is no rich edit control support.

Example

// Show the font dialog with all the default settings.
CFontDialog dlg;
dlg.DoModal();

// Show the font dialog with 12 point "Times New Roman" as the 
// selected font.
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));

CClientDC dc(this);
lf.lfHeight = -MulDiv(12, dc.GetDeviceCaps(LOGPIXELSY), 72);
_tcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Times New Roman"));

CFontDialog fdlg(&lf);
fdlg.DoModal();

Requirements

Header: afxdlgs.h

See Also

Reference

CFontDialog Class

Hierarchy Chart

CFontDialog::DoModal

Other Resources

CFontDialog Members