I am trying to get the real screen resolution (in pixels) in a windows C++ app. When the windows dpi setting is changed, I get the virtual (adjusted) resolution instead of the r
I finally found out what is happening, with the help of Jonathan Potter and Barmak Shemirani: Windows 10, unlike previous versions of windows, allows the user to change the dpi settings 'on the fly', without the need to log out and login again. I was running the tests on a win 10 machine which normally has standard (100%) settings. So I would change the setting to 150%, run the app and get the wrong results.
Jonathan and Barmak's answers indicated that there is something in the specific PC's settings, not in the program or win 10 in general, that was causing my problems. So I tried the following:
- changed DPI settings to 150%
- logged out
- logged in again
- ran the program
And I got the correct results (real screen resolution, vs adjusted one).
So it seems that in order for SetProcessDPIAware (and the related approaches: SetProcessDpiAwareness() and manifest with true) to work correctly, one has to log out and login again after changing the DPI setting and before running the program.
Thanks again, Jonathan and Barmak!