From 3e2a7cca720d574953ff9e996741688961f2d274 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 24 Aug 2014 15:31:27 +0000 Subject: [PATCH] Show new style Windows directory selector even for non-existent paths. Passing an invalid initial directory to wxDirDialog resulted in using the old style Windows directory selector dialog instead of the new style (file dialog like) one, which was unintentional, as incorrect initial directory shouldn't prevent the dialog from being shown. Fix this by handling ERROR_FILE_NOT_FOUND error specifically and still showing the new dialog, just without the (non existent) initial directory value, in this case. Closes #16430. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77464 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/dirdlg.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/msw/dirdlg.cpp b/src/msw/dirdlg.cpp index b6a3360b67..223bc85464 100644 --- a/src/msw/dirdlg.cpp +++ b/src/msw/dirdlg.cpp @@ -386,17 +386,26 @@ int wxDirDialog::ShowIFileDialog(WXHWND owner) NULL, wxIID_PPV_ARGS(IShellItem, &folder)); - if ( FAILED(hr) ) - { - wxLogApiError(wxS("SHCreateItemFromParsingName"), hr); - return wxID_NONE; - } - hr = fileDialog->SetFolder(folder); + // Failing to parse the folder name is not really an error, we'll just + // ignore the initial directory in this case, but we should still show + // the dialog. if ( FAILED(hr) ) { - wxLogApiError(wxS("IFileDialog::SetFolder"), hr); - return wxID_NONE; + if ( hr != HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ) + { + wxLogApiError(wxS("SHCreateItemFromParsingName"), hr); + return wxID_NONE; + } + } + else // The folder was parsed correctly. + { + hr = fileDialog->SetFolder(folder); + if ( FAILED(hr) ) + { + wxLogApiError(wxS("IFileDialog::SetFolder"), hr); + return wxID_NONE; + } } }