在头文件 AFXDLGS.H 中有如下共用对话框定义
// AFXDLGS - MFC Standard dialogs
// Classes declared in this file
// CDialog
class CCommonDialog; // implementation base class
// modeless dialogs
class CFindReplaceDialog; // Find/FindReplace dialog
// modal dialogs
class CFileDialog; // FileOpen/FileSaveAs dialogs
class CColorDialog; // Color picker dialog
class CFontDialog; // Font chooser dialog
class CPrintDialog; // Print/PrintSetup dialogs
class CPageSetupDialog; // Page Setup dialog
// CWnd
class CPropertySheet; // implements tabbed dialogs
class CPropertySheetEx;
// CDialog
class CPropertyPage; // Used with CPropertySheet for tabbed dialogs
class CPropertyPageEx;
下面一一介绍一下
CommonDialog 所有通用对话框的基类
CFileDialog 寻找文件对话框
CFileDialog(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs
LPCTSTR lpszDefExt = NULL,//默认扩展名 "*.*"
LPCTSTR lpszFileName = NULL,//文件名
DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,//对话框属性
LPCTSTR lpszFilter = NULL,//过滤字符串 "All Files(*.*)|*.*|All Files(*.*)|*.*||"
CWnd* pParentWnd = NULL);//父窗口指针
GetPathName() //返回路径
GetFileName() //返回文件名
GetFileExt() //返回文件后缀
GetFileTitle() //返回文件标题
CColorDialog 颜色选择对话框
CColorDialog(COLORREF clrInit = 0,//初始颜色
DWORD dwFlags = 0,//对话框属性
CWnd* pParentWnd = NULL);//父窗口
GetColor() //返回选择的颜色 0x00bbggrr
CFontDialog 字体选择对话框
CFontDialog(LPLOGFONT lplfInitial = NULL,//LOGFONT 结构 设置初始字体
DWORD dwFlags = CF_EFFECTS | CF_SCREENFONTS,//对话框属性
CDC* pdcPrinter = NULL,//打印机CDC对象
CWnd* pParentWnd = NULL);//父窗口
GetCurrentFont()//返回字体指针*LOGFONT
GetFaceName()//返回字体名称CString
GetStyleName()//返回风格CString
GetSize()//返回所选字体尺寸(10像素为单位)
GetColor()//返回所选字体颜色COLORREF
CPrintDialog 打印对话框类
CPrintDialog(BOOL bPrintSetupOnly,// TRUE for Print Setup, FALSE for Print Dialog
DWORD dwFlags = PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS| PD_HIDEPRINTTOFILE | PD_NOSELECTION,
CWnd* pParentWnd = NULL);
GetCopies()//返回副本数
GetDefaults()//返回打印机默认设置
GetDeviceName()//返回一个包含打印机设备名的CString对象
GetDevMode()//返回指向DEVMODE结构的指针,设备初始化信息和设备环境信息
GetDriverName()//返回包含打印机驱动程序名的CString
GetFromPage()//返回打印范围的起始范围
GetToPage()//返回结束范围
GetPortName()//返回打印端口CString
GetPrinterDC()//返回打印设备HDC句柄
PrintAll()//如果全部打印,则返回TRUE
PrintCollate()//如选择校对副本,则返回TRUE
PrintRange()//如果只打印一部分,则返回TRUE
PrintSelectrion()//如果打印选择的部分文档,则返回TRUE
CPageSetupDialog 页面设置对话框
CPageSetupDialog(DWORD dwFlags = PSD_MARGINS | PSD_INWININIINTLMEASURE,//对话框属性
CWnd* pParentWnd = NULL);//父窗口
可访问 PAGESETUPDLG m_psd;
LPDEVMODE GetDevMode() const; // return DEVMODE
CString GetDriverName() const; // return driver name
CString GetDeviceName() const; // return device name
CString GetPortName() const; // return output port name
HDC CreatePrinterDC();
CSize GetPaperSize() const;//返回页面大小
void GetMargins(LPRECT lpRectMargins, LPRECT lpRectMinMargins) const;//返回矩形
CFindReplaceDialog 查找替换对话框 (非模态对话框,使用Create创建,使用ShowWindow(SW_SHOW))显示
BOOL Create(BOOL bFindDialogOnly, // TRUE for Find, FALSE for FindReplace
LPCTSTR lpszFindWhat,//默认值
LPCTSTR lpszReplaceWith = NULL,//默认值
DWORD dwFlags = FR_DOWN,//属性
CWnd* pParentWnd = NULL);//父窗口
static CFindReplaceDialog* PASCAL GetNotifier(LPARAM lParam);//返回前一个对话框指针
CString GetReplaceString() const;// get replacement string
CString GetFindString() const; // get find string
BOOL SearchDown() const; // TRUE if search down, FALSE is up
BOOL FindNext() const; // TRUE if command is find next
BOOL MatchCase() const; // TRUE if matching case
BOOL MatchWholeWord() const; // TRUE if matching whole words only
BOOL ReplaceCurrent() const; // TRUE if replacing current string
BOOL ReplaceAll() const; // TRUE if replacing all occurrences
BOOL IsTerminating() const; // TRUE if terminating dialog