EnumDisplayMonitors, MonitorFromPoint giving inconsistent info when on a scaled desktop

Holland, RD (DI SW ME PRD SDE AS) 31 Reputation points
2023-07-13T19:41:43.3833333+00:00

I am running my app with the system aware DPI contect. I have three monitors. The primary monitor is my 4k monitor scaled at 200%. When I enum the monitors, the primary monitor info returned shows the monitor is 3840 x 2100, which happens to be the display resolution of that monitor. My other two monitors are are not 4k monitors. The display resolution for each is 1680 X 1050 and 1920 x 1080. The enumerator is sending the info back on those as 3360 x 2100 and 3840 x 2160 respectively. This info is scaled by my DPI scale of 200% set on my primary monitor.

Why is the enumertor feeding me a monitor info for the primary monitor that is not scaled while the other two infos contained scaled information? I added a call to GetMonitorFromPoint passing in a point on the main display and it gives the same unscaled information. So, at least that's consistent.

Since I have one to the left of the primary and the other to the right, I am getting these rcMonitor rects back, which shows my code that the primary (middle) monitor and the one to its right are disjoint:

(-3360,28) - (0, 2128) (0,0) - (3840,2160) (7680,-34) - (11520,2126)

I have to adjust the results by scaling the primary monitor info when the DPI awareness context is DPI_AWARENESS_CONTEXT_SYSTEM_AWARE. That is a bit odd, and unexpected by me.

Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
4,498 questions
0 comments No comments
{count} vote