FileChooser filters

I’m having some trouble getting the native open/save file dialog to act exactly like a normal Win32 dialog. No matter what combination of commas, semicolons, \0’s, etc I put in the filename filter, I can’t get the Save As Type combobox to show multiple groups of file filters.

Here’s an example filter string that works with the Win32 OpenFileName API: “PNG(.png)\0.png\0JPEG(.jpg,.jpeg)\f*.jpg;*.jpeg\0\0”. With that string, I should get two possible selections in the combobox.

It seems pretty obvious that the problem is related to the null terminators that don’t actually terminate the string (thanks MS :roll:). My questions are the following:

  1. What options do I have as far as a workaround?

  2. Is there any possibility of adding a new filter string format for JUCE, which would automatically translate to the convoluted Windows format when filling the OPENFILENAME struct?

Well the juce filter just uses the WildcardFileFilter class, so check that out for info about the string format. It doesn’t handle all the stuff you’ve got there with names in brackets, it’s just a straightforward wildcard.

Well, sure, I get that. Maybe I should explain what I’m actually trying to do.

Basically, I’ve got an Image that I’d like to save to disk. The user should be able to choose between a PNG and a JPEG. So, I’d like it to work like a typical Windows app: you type in the filename, sans extension, and select the file type from the drop-down. Hit save, and it saves the file including the extension.

Clearly this won’t work with a simple WildcardFileFilter, so the user has to type in the extension, or I have to make a guess. It’s not exactly the end of the world, but it’s an annoyance. In the meantime, I suppose I should be able to manually create the file open and close dialogs.

Sorry, I didn’t read your feature request there - yes, it’d be a useful thing to have, but I’ve no time at the moment to look at it… I’ll add it to my big list, though!