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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user