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

File and Message Dialogs not Parented to Calling Thread's Window #93

Open
Voxtric opened this issue Sep 14, 2023 · 0 comments
Open

File and Message Dialogs not Parented to Calling Thread's Window #93

Voxtric opened this issue Sep 14, 2023 · 0 comments

Comments

@Voxtric
Copy link

Voxtric commented Sep 14, 2023

Both the file dialog and the message dialogs use GetActiveWindow to parent the dialogs to the calling window. However, according to https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getactivewindow, this function only returns the active window for the calling thread, and as the use of these Windows APIs are in the asynchronous executor, GetActiveWindow always returns NULL.

I've implemented and tested a fix for this, which can be found in the uploaded file (extension renamed so that I could upload it).
portable-file-dialogs.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