samhocevar / portable-file-dialogs

💬 Portable GUI dialogs library, C++11, single-header
Do What The F*ck You Want To Public License
1.03k stars 99 forks source link

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

Open gamagan opened 1 year ago

gamagan commented 1 year ago

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