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

With desktop scaling enabled, icon is incorrectly placed #52

Closed
Nutzzz opened this issue Jul 16, 2022 · 2 comments
Closed

With desktop scaling enabled, icon is incorrectly placed #52

Nutzzz opened this issue Jul 16, 2022 · 2 comments

Comments

@Nutzzz
Copy link
Contributor

Nutzzz commented Jul 16, 2022

image

@Nutzzz
Copy link
Contributor Author

Nutzzz commented Jul 27, 2022

I've been working on this, so I figured I'd post an update.

First stumbling block: A method that gives me a usable scale or DPI for a command line program. I tried many possibilities, but I finally found one that worked for me: GetDpiForWindow() in user32.dll. Divide by 96, and you get the scaling percentage; though note this requires Windows 10 1607. The manifest need not be adjusted to change DPI_AWARENESS.

Now it's on to the second stumbling block: It seems the GDI surface needs to be resized as well somehow. Multiplying x, y, w, and h by the scaling factor moves the image out of the visible area. By multiplying just w and h, the problem becomes clear:

image

EDIT:
Just to be clear, having gdiScaling set to true and/or dpiAware set to true/pm and dpiAwareness set to PerMonitorV2,PerMonitor [in the manifest] doesn't change the observed behavior.

EDIT 2:
Hm, interesting. Going to the Compatibility tab for glc.exe and changing "Change high DPI settings" > "Override high DPI scaling behavior" to "Application" it working.

image

However, I'm having difficulty so far reproducing the equivalent behavior by changing the app.manifest, App.config, or programatically. I could force the compatibility registry setting, but I'd rather not resort to that except as a last resort.

@Nutzzz
Copy link
Contributor Author

Nutzzz commented Jul 29, 2022

This did the trick:
SetProcessDpiAwarenessContext(GetAwarenessFromDpiAwarenessContext(GetThreadDpiAwarenessContext()) - 3); // DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE

EDIT: Fixed in PR #54

@Nutzzz Nutzzz closed this as completed Aug 2, 2022
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