CCommonDialog及其子类
首先,CCommonDialog派生于CDialog,它本身只有一个构造函数
CCommonDialog的子类包括:
CFileDialog,CFontDialog,CColorDialog,CPageSetupDialog,
CPrintDialog,CPrintDialogEx,
CFindReplaceDialog,COleDialog
(这里仅介绍CFontDialog,因为所有这些对话框的操作都是相似的,所以可以举一反三)
CFontDialog
直接使用:
调用CFontDialog的构造函数;
调整CHOOSEFONT结构;
调用CFontDialog::DoModal()函数;
若用户选择后点了OK按钮,则返回ID_OK,此时可以使用CFontDialog的成员函数来取得用户的输入。
成员:Data Members
A structure used to customize a CFontDialog object. |
Construction
Constructs a CFontDialog object. |
Operations
Displays the dialog and allows the user to make a selection. | |
Retrieves the character formatting of the selected font. | |
Returns the color of the selected font. | |
Retrieves the name of the currently selected font. | |
Returns the face name of the selected font. | |
Returns the point size of the selected font. | |
Returns the style name of the selected font. | |
Returns the weight of the selected font. | |
Determines whether the font is bold. | |
Determines whether the font is italic. | |
Determines whether the font is displayed with strikeout. | |
Determines whether the font is underlined. |
其中,CHOOSEFONT结构为:
typedef struct {
DWORD lStructSize;//该结构的大小,以byte衡量
HWND hwndOwner;//父窗口
HDC hDC;//若Flags值非CF_PRINTERFONT或CF_BOTH时,该值被忽略
LPLOGFONT lpLogFont;//该值定义了字体的一系列属性,参见MSDN
INT iPointSize;//以点的1/10为单位
DWORD Flags;//参见MSDN
COLORREF rgbColors;//一个RGB颜色值
LPARAM lCustData;
LPCFHOOKPROC lpfnHook;
LPCTSTR lpTemplateName;
HINSTANCE hInstance;
LPTSTR lpszStyle;
WORD nFontType;
INT nSizeMin;
INT nSizeMax;
} CHOOSEFONT, *LPCHOOSEFONT;