Skip to content
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

Patch attached: Support passing owner HWND to dialog constructors. #82

Open
gamagan opened this issue Mar 9, 2023 · 0 comments
Open

Comments

@gamagan
Copy link

gamagan commented Mar 9, 2023

Hello,

Thank you for making this library. It works great on Windows 10.

I'm using the library to add file Open/Save support to a Vulkan-based renderer. PFD works well, except that the Dialog windows open up without being attached to the parent window (the renderer), so they are not modal. As you can understand, this non-standard behavior is problematic in a few ways.

I noticed there are calls to functions such as GetActiveWindow(). However, in the codebase I work on, that function returns null -- this is on Windows 10, 64bits. I made some updates to the dialog constructors to be able to pass the parent HWND to PFD, for use when creating the dialogs. This makes it so that the dialogs are created as modal, and so completely solve the issues that I was having. The downside is that my changes are only applicable to Windows.

Please find attached a patch with the changes I made in order to support this. Please consider patching the PFD code to include something that provides this kind of functionality: to be able to pass the parent HWND for the dialogs to use. Of course, you can just use the patch I'm attaching as is.

I hearby license this patched the same as PFD, with the WTFPL license.

Thanks again for the nice library.

pfd.diff.txt

samangh added a commit to samangh/portable-file-dialogs that referenced this issue Mar 12, 2024
`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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant