I have a manifest containing:
<asmv3:windowsSettings xmlns='http://schemas.microsoft.com/SMI/2005/WindowsSettings'>
<dpiAware>True/PM</dpiAware>
</asmv3:windowsSettings>
<asmv3:windowsSettings xmlns='https://schemas.microsoft.com/SMI/2016/WindowsSettings'>
<dpiAwareness>PerMonitorV2,PerMonitor</dpiAwareness>
</asmv3:windowsSettings>
I am asserting this is the case in my _tWinMain function:
#ifdef _DEBUG
{
auto context = GetThreadDpiAwarenessContext();
auto awareness = GetAwarenessFromDpiAwarenessContext(context);
assert(awareness == DPI_AWARENESS::DPI_AWARENESS_PER_MONITOR_AWARE);
}
#endif // _DEBUG
GetWindowDpiAwarenessContext also returns DPI_AWARENESS_PER_MONITOR_AWARE. I'm wondering why it doesn't return DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2, and why DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 isn't in the enum defined in WinDef.h. I'm using platform SDK version 10.0.22621.0, Visual Studio 2022 17.5.5.
The documentation claims this setting automatically scales non-client areas of my window. However it does not. On my 4K monitor the non-client areas are tiny. The rest of the application correctly calculates the scale factor for the components I scale myself however.
I have checked the .exe properties in Explorer to make sure there's no behaviour override going on. Both boxes on its high DPI settings are unchecked.
What mistake have I made? Or does this stuff just not work correctly out of the box?
EDIT: If I call EnableNonClientDpiScaling in WM_NCCREATE, I get the correct non-client area scaling. This is a hint that my process, thread or window isn't DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2. It must just be as it said, DPI_AWARENESS_PER_MONITOR_AWARE. So the question then, is why, when I specified _V2 in the manifest.