I\'ve run into an interesting problem. At least in Vista, getSystemMetrics(SM_CXSCREEN) returns an incorrect value when the desktop DPI settings aren\'t set at 100%. For exa
Before getting the correct pixel metrics from functions like GetSystemMetrics, or GetClientRect, your app must declare to the OS that it knows about DPI and therefore won't screw everything up.
There have been several changes to how this is recommended. See the MSDN docs for more details.
From Windows 10 onwards:
::SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_SYSTEM_AWARE);
Or from Windows 8.1 onwards:
::SetProcessDpiAwareness(DPI_AWARENESS_CONTEXT_SYSTEM_AWARE);
Or from Vista onwards:
::SetProcessDPIAware();
After calling this, the function GetSystemMetrics etc. should return the correct values to your app in pixels.