summaryrefslogtreecommitdiff
path: root/ui/IFileDialog_Vista/ifile_dialog.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:21:59 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:21:59 +0200
commitd4af25c52a28b93484ffb55e0a8027bc4ce7856f (patch)
tree853d57468d6b370711e7a5dd2c3dc7d5bac81b10 /ui/IFileDialog_Vista/ifile_dialog.cpp
parent5.8 (diff)
downloadFreeFileSync-d4af25c52a28b93484ffb55e0a8027bc4ce7856f.tar.gz
FreeFileSync-d4af25c52a28b93484ffb55e0a8027bc4ce7856f.tar.bz2
FreeFileSync-d4af25c52a28b93484ffb55e0a8027bc4ce7856f.zip
5.9
Diffstat (limited to 'ui/IFileDialog_Vista/ifile_dialog.cpp')
-rw-r--r--ui/IFileDialog_Vista/ifile_dialog.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/ui/IFileDialog_Vista/ifile_dialog.cpp b/ui/IFileDialog_Vista/ifile_dialog.cpp
index 8c3e694c..565dfa1a 100644
--- a/ui/IFileDialog_Vista/ifile_dialog.cpp
+++ b/ui/IFileDialog_Vista/ifile_dialog.cpp
@@ -19,6 +19,7 @@ namespace
{
bool showFolderPickerImpl(HWND ownerWindow, //throw ComError; return "false" if cancelled by user
const wchar_t* defaultFolder, //optional!
+ const GUID* persistenceGuid, //
std::wstring& selectedFolder)
{
ComPtr<IFileDialog> fileDlg;
@@ -27,6 +28,9 @@ bool showFolderPickerImpl(HWND ownerWindow, //throw ComError; return "false" if
CLSCTX_ALL,
IID_PPV_ARGS(fileDlg.init())));
+ if (persistenceGuid)
+ ZEN_CHECK_COM(fileDlg->SetClientGuid(*persistenceGuid));
+
FILEOPENDIALOGOPTIONS dlgOptions = 0;
ZEN_CHECK_COM(fileDlg->GetOptions(&dlgOptions)); //throw ComError
ZEN_CHECK_COM(fileDlg->SetOptions(dlgOptions | FOS_PICKFOLDERS | FOS_NOVALIDATE | FOS_FORCEFILESYSTEM));
@@ -57,7 +61,7 @@ bool showFolderPickerImpl(HWND ownerWindow, //throw ComError; return "false" if
return true;
}
-const wchar_t* allocString(const std::wstring& msg) //ownership passed
+wchar_t* allocString(const std::wstring& msg) //ownership passed
{
auto tmp = new wchar_t [msg.size() + 1]; //std::bad_alloc ?
::wmemcpy(tmp, msg.c_str(), msg.size() + 1); //include 0-termination
@@ -69,9 +73,10 @@ const wchar_t* allocString(const std::wstring& msg) //ownership passed
void ifile::showFolderPicker(void* ownerWindow,
const wchar_t* defaultFolder,
- const wchar_t*& selectedFolder,
+ const GuidProxy* guid,
+ wchar_t*& selectedFolder,
bool& cancelled,
- const wchar_t*& errorMsg)
+ wchar_t*& errorMsg)
{
selectedFolder = nullptr;
cancelled = false;
@@ -79,8 +84,13 @@ void ifile::showFolderPicker(void* ownerWindow,
try
{
+ static_assert(sizeof(GuidProxy) == sizeof(GUID), "");
+ GUID winGuid = {};
+ if (guid)
+ ::memcpy(&winGuid, guid, sizeof(GUID));
+
std::wstring folderPath;
- if (showFolderPickerImpl(static_cast<HWND>(ownerWindow), defaultFolder, folderPath)) //throw ComError
+ if (showFolderPickerImpl(static_cast<HWND>(ownerWindow), defaultFolder, guid ? &winGuid : nullptr, folderPath)) //throw ComError
selectedFolder = allocString(folderPath);
else
cancelled = true;
bgstack15