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 GetWindowDpiAwarenessContext NULL check #26

Merged
merged 3 commits into from
Nov 8, 2024

Conversation

nulano
Copy link

@nulano nulano commented Nov 7, 2024

Fix for my suggestion for #8456

I also slightly simplified the code and removed the use of the DPI_AWARENESS_CONTEXT type - IIRC it was not available in VS2017.

src/display.c Outdated Show resolved Hide resolved
Comment on lines +363 to +366
GetWindowDpiAwarenessContext_function = (Func_GetWindowDpiAwarenessContext
)GetProcAddress(user32, "GetWindowDpiAwarenessContext");
if (screens == -1 && GetWindowDpiAwarenessContext_function != NULL) {
dpiAwareness = GetWindowDpiAwarenessContext_function(wnd);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GetWindowDpiAwarenessContext_function = (Func_GetWindowDpiAwarenessContext
)GetProcAddress(user32, "GetWindowDpiAwarenessContext");
if (screens == -1 && GetWindowDpiAwarenessContext_function != NULL) {
dpiAwareness = GetWindowDpiAwarenessContext_function(wnd);
if (screens == -1) {
GetWindowDpiAwarenessContext_function = (Func_GetWindowDpiAwarenessContext
)GetProcAddress(user32, "GetWindowDpiAwarenessContext");
if (GetWindowDpiAwarenessContext_function != NULL) {
dpiAwareness = GetWindowDpiAwarenessContext_function(wnd);
}

So your feeling is that your current version is simpler than this suggestion? I think your version is also probably fine.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally find fewer nested if statements to be easier to read.

@radarhere radarhere merged commit c5e89ee into radarhere:imagegrab Nov 8, 2024
43 of 46 checks passed
@nulano nulano deleted the imagegrab-dynamic-link branch November 8, 2024 17:15
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