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

Fix restoring window geometry #392

Merged
merged 2 commits into from
Feb 22, 2024
Merged

Conversation

vadz
Copy link
Contributor

@vadz vadz commented Feb 21, 2024

This fixes the problem of #370 and also restoring the window when it was closed in maximized state.

The coordinates returned by GetWindowPlacement() must be passed to
SetWindowPlacement() and not SetWindowPos() as the former functions
account correctly for non-standard DPI, while the latter one does not.

Using SetWindowPlacement() also allows to remove the checks for the
coordinates being valid because the function already checks for this and
will always position the window inside the visible area anyhow.

Fixes CobaltFusion#370.
If the window was closed in the maximized (or, more rarely, but still
possible, minimized) state, restore it in the same state during the next
run.

Take care to use the appropriate show command for the ShowWindow() call
done in Main(), as using SW_SHOWMAXIMIZED with SetWindowPlacement()
doesn't work quite as expected.
@janwilmans janwilmans merged commit 47d8577 into CobaltFusion:develop Feb 22, 2024
1 check failed
@vadz vadz deleted the fix-geom-restore branch February 22, 2024 13:26
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

Successfully merging this pull request may close these issues.

2 participants