I would like to talk about an issue with Windows that I see very often and which is bothering me.
Imagine that I use Reaper 64 bits on Windows 8 and save / render an audio file somewhere after having opened a native Save As dialog box. Then, I close Reaper, I open another project, I load a plug-in where there is a TextButton allowing me to use a native Open Dialog box to select a file.
That native window is opened with JUCE FileChooser::browseForFileToOpen, and I set a very specific folder there for the initial path with the FileChooser constructor argument “initialFileOrDirectory”. However, the initial path I see in the native Open dialog box isn’t the one I specified, but the last path I used in the other Reaper project instead…
Is it a Reaper issue ? A JUCE issue ? After some research, I found the guilty : it’s the WIN32 API !
Here is what they say :
The initial directory. The algorithm for selecting the initial directory varies on different platforms.
- If lpstrInitialDir has the same value as was passed the first time the application used an Open or Save As dialog box, the path most recently selected by the user is used as the initial directory.
- Otherwise, if lpstrFile contains a path, that path is the initial directory.
- Otherwise, if lpstrInitialDir is not NULL, it specifies the initial directory.
- If lpstrInitialDir is NULL and the current directory contains any files of the specified filter types, the initial directory is the current directory.
- Otherwise, the initial directory is the personal files directory of the current user.
- Otherwise, the initial directory is the Desktop folder.
Really stupid isn’t it ? In some random cases, the parameter is ignored, and there is nothing to do about it with the given input parameters.
I don’t know if there is an easy workaround for that (such as resetting in the registry that previous folder, or opening a fake dialog with a random initial folder before each call) but at least I think it would be important to talk about the issue in the FileChooser documentation.