Skip to content

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.

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
radarhere added a commit that referenced this pull request Mar 19, 2025
Co-authored-by: Andrew Murray <[email protected]>
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