Windows 11, PerMonitorV2 is NOT automatically scaling non-client areas of my window.

Robinson 156 Reputation points

I have a manifest containing:

<asmv3:windowsSettings xmlns=''>
<asmv3:windowsSettings xmlns=''>

I am asserting this is the case in my _tWinMain function:

#ifdef _DEBUG
		auto context = GetThreadDpiAwarenessContext();
		auto awareness = GetAwarenessFromDpiAwarenessContext(context);


#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.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,471 questions
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,591 questions
{count} votes

Accepted answer
  1. Xiaopo Yang - MSFT 11,746 Reputation points Microsoft Vendor

    Older APIs offer less functionality. Have you checked your process DPI Awareness in Task Manager? Have you tried to set default awareness programmatically with recommended SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2)?

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful