X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f6bcfd974ef26faf6f91a62cac09827e09463fd1..4def3b359546ee186b3db723db719f85b761f36a:/src/msw/filedlg.cpp?ds=sidebyside diff --git a/src/msw/filedlg.cpp b/src/msw/filedlg.cpp index c81dfcdf52..73a9a8128d 100644 --- a/src/msw/filedlg.cpp +++ b/src/msw/filedlg.cpp @@ -118,7 +118,7 @@ wxString wxFileSelector(const wxChar *title, flags, wxPoint(x, y)); if( wxStrlen(defaultExtension) != 0 ) { - int filterFind = 1, + int filterFind = 0, filterIndex = 0; for( unsigned int i = 0; i < filter2.Len(); i++ ) @@ -127,7 +127,6 @@ wxString wxFileSelector(const wxChar *title, { // save the start index of the new filter unsigned int is = i++; - filterIndex++; // find the end of the filter for( ; i < filter2.Len(); i++ ) @@ -139,25 +138,26 @@ wxString wxFileSelector(const wxChar *title, if( i-is-1 > 0 && is+1 < filter2.Len() ) { if( filter2.Mid(is+1,i-is-1).Contains(defaultExtension) ) -// if( filter2.Mid(is+1,i-is-1) == defaultExtension ) { filterFind = filterIndex; break; } } + + filterIndex++; } } fileDialog.SetFilterIndex(filterFind); } + wxString filename; if ( fileDialog.ShowModal() == wxID_OK ) { - wxStrcpy(wxBuffer, (const wxChar *)fileDialog.GetPath()); - return wxBuffer; + filename = fileDialog.GetPath(); } - else - return wxGetEmptyString(); + + return filename; } @@ -172,22 +172,28 @@ wxString wxFileSelectorEx(const wxChar *title, int y) { - wxFileDialog fileDialog(parent, title ? title : wxT(""), defaultDir ? defaultDir : wxT(""), - defaultFileName ? defaultFileName : wxT(""), filter ? filter : wxT(""), flags, wxPoint(x, y)); + wxFileDialog fileDialog(parent, + title ? title : wxT(""), + defaultDir ? defaultDir : wxT(""), + defaultFileName ? defaultFileName : wxT(""), + filter ? filter : wxT(""), + flags, wxPoint(x, y)); + wxString filename; if ( fileDialog.ShowModal() == wxID_OK ) { - *defaultFilterIndex = fileDialog.GetFilterIndex(); - wxStrcpy(wxBuffer, (const wxChar *)fileDialog.GetPath()); - return wxBuffer; + if ( defaultFilterIndex ) + *defaultFilterIndex = fileDialog.GetFilterIndex(); + + filename = fileDialog.GetPath(); } - else - return wxGetEmptyString(); + + return filename; } wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard, - long style, const wxPoint& pos) + long style, const wxPoint& WXUNUSED(pos)) { m_message = message; m_dialogStyle = style; @@ -323,8 +329,8 @@ int wxFileDialog::ShowModal() //== Execute FileDialog >>================================================= - bool success = (m_dialogStyle & wxSAVE) ? (GetSaveFileName(&of) != 0) - : (GetOpenFileName(&of) != 0); + bool success = (m_dialogStyle & wxSAVE ? GetSaveFileName(&of) + : GetOpenFileName(&of)) != 0; DWORD errCode = CommDlgExtendedError();