您的位置:首页 > 其它

CCommonDialog及其子类

2006-09-02 21:42 127 查看
CCommonDialog及其子类
首先,CCommonDialog派生于CDialog,它本身只有一个构造函数
CCommonDialog的子类包括:
CFileDialog,CFontDialog,CColorDialog,CPageSetupDialog,
CPrintDialog,CPrintDialogEx,
CFindReplaceDialog,COleDialog
(这里仅介绍CFontDialog,因为所有这些对话框的操作都是相似的,所以可以举一反三)
 

CFontDialog
直接使用:
调用CFontDialog的构造函数;
调整CHOOSEFONT结构;
调用CFontDialog::DoModal()函数;
若用户选择后点了OK按钮,则返回ID_OK,此时可以使用CFontDialog的成员函数来取得用户的输入。
成员:Data Members
m_cf
A structure used to customize a CFontDialog object.
Construction
CFontDialog
Constructs a CFontDialog object.
Operations
DoModal
Displays the dialog and allows the user to make a selection.
GetCharFormat
Retrieves the character formatting of the selected font.
GetColor
Returns the color of the selected font.
GetCurrentFont
Retrieves the name of the currently selected font.
GetFaceName
Returns the face name of the selected font.
GetSize
Returns the point size of the selected font.
GetStyleName
Returns the style name of the selected font.
GetWeight
Returns the weight of the selected font.
IsBold
Determines whether the font is bold.
IsItalic
Determines whether the font is italic.
IsStrikeOut
Determines whether the font is displayed with strikeout.
IsUnderline
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;
 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息