Using CFolderPickerDialog for the purpose of 'Save As' (MFC)

1.4k Views Asked by At

I would like to use a CFolderPickerDialog instance for the purpose of 'Save As'.

In other words, the user will input the name of a (new) folder, which I can then create.

With the CFileDialog base class, this can be done during construction via the first input argument:

BOOL bOpenFileDialog // TRUE for FileOpen, FALSE for FileSaveAs

How can I go about achieving the same functionality for a CFolderPickerDialog instance?

1

There are 1 best solutions below

3
Santosh Dhanawade On

You can not achieve this with CFolderPickerDialog as per my understanding. Le me explain you this. Base class of CFolderPickerDialog is CFileDialog and bOpenFileDialog the flag which will allow you to launch file dialog as open or save.

Since, CFolderPickerDialog is child class hence microsoft has to provide call to parent (CFileDialog) in constructor. If you open dlgfile.cpp from ..\Microsoft Visual Studio 14.0\VC\atlmfc\src\mfc\ then you will get source code of CFolderPickerDialog class.

Now coming to point, if you observe the constructor of CFolderPickerDialog then you get exact reason why its not possible.

////////////////////////////////////////////////////////////////////////////
// Folder Picker common dialog helper

CFolderPickerDialog::CFolderPickerDialog(LPCTSTR lpszFolder, DWORD dwFlags, CWnd* pParentWnd, DWORD dwSize, BOOL fNonFileSystemFolders) :
    CFileDialog(TRUE, NULL, lpszFolder, dwFlags, NULL, pParentWnd, dwSize, TRUE)
{
    m_bPickFoldersMode = TRUE;
    m_bPickNonFileSysFoldersMode = fNonFileSystemFolders;
}

First flag is always true that indicate unfortunately, CFolderPickerDialog will open in File Open mode only.