-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set default file extension in Windows save dialog #86
base: main
Are you sure you want to change the base?
Conversation
Questions:
|
With this commit, in a Windows file extension, if the user has not entered a file extension, then the file extension from the filter pattern will be used.
@gamagan, thanks for the questions. They caused me to look at this more closely and do some experimentation. I was actually incorrect in my previous message. As long as the I have updated my pull request to match this. In the new pull request, things should work as expected. So, for example let's say you do: pfd::save_file("Select a file", ".",
{ "Image Files", "*.png *.jpg *.jpeg *.bmp",
"AudioFiles", "*.wav *.mp3",
"All Files", "*" }); The default extension will be |
Wow. That's nice that the change turned out to be so simple for the benefits it provides. Good work. So, Windows only supports 3 letter extensions, in that case? There's no code to set the size of the buffer, so I would think that the extension size would be fixed. It wouldn't be ideal if it only supported 3 letters. |
Yes, the automatically added extensions are limited to 3 characters. This is a limitation of the deprecated The |
@samhocevar, I was wondering if you've had a chance to look at the PR? I think it's a nice uncontroversial 2-line change. |
@samhocevar? Any chance of merging this pull request? |
Yup, accepting this PR would make our lives much, much easier @samhocevar This small library is really great, it would be a waste to abandon it. |
I have the same problem, the extension is not automatically added and I'd like this to be merged too. For now, I'm using @samangh branch. I did further improve this actually so I thought I would share. I didn't wanted to open yet another PR. @samangh maybe you can update yours ?
In the end, the few lines at that place in the file become:
|
The required version number (3.5) us so old that CMake is now complaining about this. Removing a required CMake version fixes this. We don't use anything complicated so any CMake version will be compatible.
@christophe-f8 Sure, I can look at merging this in my branch. As this is meant to be a portable library I'll have to check that the same behaviour is also implemented in other environments. |
@christophe-f8, your suggested changes are now in my fork. |
[macOS] Fix save dialog when absolute path is included
`GetActiveWindow()` will return NULL if called asynchronously, as it's calling thread will not have a message loop. To work around this, use `GetForegroundWindow()` if `GetActiveWindow()` is null. This will cause any dialogs to be modal. Fixes samhocevar#82 and samhocevar#93
First of all, thank you for your work on portable-file-dialogs. It's quite useful :-).
This pull request will set the default file extension when using the file save dialog in Windows. The default file extension is set to the first file extension provided in the filter pattern.
It turns out that the
GetSaveFileNameW
function in Windows does not automatically get the file extension from the filters, instead the the default extension must be manually set. So this is what this pull request does.This should close issue #43.