Partager via


CFontDialog Class

Allows you to incorporate a font-selection dialog box into your application.

class CFontDialog : public CCommonDialog

Members

Public Constructors

Name

Description

CFontDialog::CFontDialog

Constructs a CFontDialog object.

Public Methods

Name

Description

CFontDialog::DoModal

Displays the dialog and allows the user to make a selection.

CFontDialog::GetCharFormat

Retrieves the character formatting of the selected font.

CFontDialog::GetColor

Returns the color of the selected font.

CFontDialog::GetCurrentFont

Assigns the characteristics of the currently selected font to a LOGFONT structure.

CFontDialog::GetFaceName

Returns the face name of the selected font.

CFontDialog::GetSize

Returns the point size of the selected font.

CFontDialog::GetStyleName

Returns the style name of the selected font.

CFontDialog::GetWeight

Returns the weight of the selected font.

CFontDialog::IsBold

Determines whether the font is bold.

CFontDialog::IsItalic

Determines whether the font is italic.

CFontDialog::IsStrikeOut

Determines whether the font is displayed with strikeout.

CFontDialog::IsUnderline

Determines whether the font is underlined.

Public Data Members

Name

Description

CFontDialog::m_cf

A structure used to customize a CFontDialog object.

Remarks

A CFontDialog object is a dialog box with a list of fonts that are currently installed in the system. The user can select a particular font from the list, and this selection is then reported back to the application.

To construct a CFontDialog object, use the provided constructor or derive a new subclass and use your own custom constructor.

Once a CFontDialog object has been constructed, you can use the m_cf structure to initialize the values or states of controls in the dialog box. The m_cf structure is of type CHOOSEFONT. For more information on this structure, see the Windows SDK.

After initializing the dialog object's controls, call the DoModal member function to display the dialog box and allow the user to select a font. DoModal returns whether the user selected the OK (IDOK) or Cancel (IDCANCEL) button.

If DoModal returns IDOK, you can use one of CFontDialog's member functions to retrieve the information input by the user.

You can use the Windows CommDlgExtendedError function to determine whether an error occurred during initialization of the dialog box and to learn more about the error. For more information on this function, see the Windows SDK.

CFontDialog relies on the COMMDLG.DLL file that ships with Windows versions 3.1 and later.

To customize the dialog box, derive a class from CFontDialog, provide a custom dialog template, and add a message-map to process the notification messages from the extended controls. Any unprocessed messages should be passed to the base class.

Customizing the hook function is not required.

For more information on using CFontDialog, see Common Dialog Classes.

Inheritance Hierarchy

CObject

CCmdTarget

CWnd

CDialog

CCommonDialog

CFontDialog

Requirements

Header: afxdlgs.h

See Also

Reference

CCommonDialog Class

Hierarchy Chart

Concepts

MFC Sample HIERSVR