- wxFileDialog fileDialog(parent, title, defaultDirString, defaultFilenameString, filter2, flags, wxPoint(x, y));
+ wxFileDialog fileDialog(parent, title, defaultDirString,
+ defaultFilenameString, filter2,
+ flags, wxPoint(x, y));
+ if( wxStrlen(defaultExtension) != 0 )
+ {
+ int filterFind = 1,
+ filterIndex = 0;
+
+ for( unsigned int i = 0; i < filter2.Len(); i++ )
+ {
+ if( filter2.GetChar(i) == _T('|') )
+ {
+ // save the start index of the new filter
+ unsigned int is = i++;
+ filterIndex++;
+
+ // find the end of the filter
+ for( ; i < filter2.Len(); i++ )
+ {
+ if(filter2[i] == _T('|'))
+ break;
+ }
+
+ 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;
+ }
+ }
+ }
+ }
+
+ fileDialog.SetFilterIndex(filterFind);
+ }