CFileDialog dlg

来源:百度知道 编辑:UC知道 时间:2024/05/07 13:35:14
CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"All Files(*.*)|*.*||",AfxGetMainWnd());

如果dlg是CFileDialog的对象,
对象后面加括号带参数,好像是函数,这种用法怎么解释?

CFileDialog 类中有带参数构造函数
CFileDialog( BOOL bOpenFileDialog, LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL, DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL );

而你定义的就是调用了这个函数

构造函数。
大体思想就是利用提供的参数生成一个临时对象,然后赋予一个对象。注意,这个对象是临时的,也就是说出了局部作用域,这个对象就被析构了

带参数的构造函数

这个应该明白了八

构造函数。

CFileDialog::CFileDialog
This constructor creates an instance of a standard Windows CE file dialog box-object. Either a Open or Save As dialog box is constructed, depending on the value of bOpenFileDialog.

The following code example demonstrates how to use CFileDialog to rename or move an existing file dialog box. My Documents and docs are directories and new file is the new name of the file dialog box.

CFileDialog dlg(FALSE, NULL, TEXT("\\My Documents\\docs\\new file"),
OFN_PROPERTY);

The following code example