请问如何在程序里加入“新建”?不是系统自带的。它也是在CFileDialog里定义的吗?谢谢。因为我没有装NSDN,所以学习起来很不方便,而且我又是刚刚接触vc,请详细解释,好吗?

解决方案 »

  1.   

    CFileDialog::CFileDialog
    CFileDialog( BOOL bOpenFileDialog, LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL, DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL );ParametersbOpenFileDialogSet to TRUE to construct a File Open dialog box or FALSE to construct a File Save As dialog box.lpszDefExtThe default filename extension. If the user does not include an extension in the Filename edit box, the extension specified by lpszDefExt is automatically appended to the filename. If this parameter is NULL, no file extension is appended.lpszFileNameThe initial filename that appears in the filename edit box. If NULL, no filename initially appears.dwFlagsA combination of one or more flags that allow you to customize the dialog box. For a description of these flags, see theOPENFILENAME structure in the Win32 SDK documentation. If you modify the m_ofn.Flags structure member, use a bitwise-OR operator in your changes to keep the default behavior intact.lpszFilterA series of string pairs that specify filters you can apply to the file. If you specify file filters, only selected files will appear in the Files list box. See the Res section for more information on how to work with file filters.pParentWndA pointer to the file dialog-box object’s parent or owner window.ResCall this function to construct a standard Windows file dialog box-object. Either a File Open or File Save As dialog box is constructed, depending on the value of bOpenFileDialog.To allow the user to select multiple files, set the OFN_ALLOWMULTISELECT flag before calling DoModal. You need to supply your own filename buffer to accommodate the returned list of multiple filenames. Do this by replacing m_ofn.lpstrFile with a pointer to a buffer you have allocated, after constructing the CFileDialog, but before calling DoModal. Additionally, you must set m_ofn.nMaxFile with the number of characters in the buffer pointed to by m_ofn.lpstrFile.To allow the user to resize an Explorer-style dialog box using either the mouse or keyboard, set the OFN_ENABLESIZING flag. Setting this flag is necessary only if you provide a hook procedure or custom template. The flag works only with an Explorer-style dialog box; old-style dialog boxes do not permit resizing. The lpszFilter parameter is used to determine the type of filename a file must have to be displayed in the file list box. The first string in the string pair describes the filter; the second string indicates the file extension to use. Multiple extensions may be specified using ‘;’ as the delimiter. The string ends with two ‘|’ characters, followed by a NULL character. You can also use a CString object for this parameter.For example, Microsoft Excel permits users to open files with extensions .XLC (chart) or .XLS (worksheet), among others. The filter for Excel could be written as:static char BASED_CODE szFilter[] = "Chart Files (*.xlc)|*.xlc|Worksheet Files (*.xls)|*.xls|Data Files (*.xlc;*.xls)|*.xlc; *.xls|All Files (*.*)|*.*||";
     
      

  2.   

    楼上的朋友,可是我怎么都不能把“新建”加进来,我只能作到加入“打开”和“保存”。那个名字是在那里定义的。上面的语句不是只能定义Open和SaveAs吗?谢谢。
      

  3.   

    派生一个新类,以CFileDialog为基类。重载OnInitDialog函数改变对话框大小。动态添加按钮控件,为了从增加的控件中得到信息,注意要响应WM_DESTROY消息,思路是这样的吧
      

  4.   

    CSDN里就没有提供一个象菜单里的“保存”,“打开”一样的建立方法吗?必须要从新派生一个新类吗?有这类例子吗?谢谢,送我一个。不胜感激。