Noitidart
Noitidart

Reputation: 37228

How to get multi-monitor resolution in Process_System_DPI_Aware

I am making an addon for Firefox. Firefox is set to Process_System_DPI_Aware. I have handles to the monitors, is it possible to get the correct monitor rect?

All methods I tried so far are giving me the DPI of the primary monitor.

I thought to use LogicalToPhysicalPointForPerMonitorDPI as it says it should work however I don't have a window to give to the function. The second monitor has no windows on it. I'm trying to take a screenshot of that desktop.

Thanks

Upvotes: 0

Views: 580

Answers (2)

guest
guest

Reputation: 11

You can create invisible window, enumerate monitors using EnumDisplayMonitors, get virtualized rects using GetMonitorInfo, move and resize invisible window fullscreen for each monitor, and get real monitor rect using LogicalToPhysicalPointForPerMonitorDPI.

Upvotes: 1

David Heffernan
David Heffernan

Reputation: 612794

You are using per-monitor dpi settings but your process is not per-monitor dpi aware. Thus, your secondary monitor has dpi virtualization.

You should perform your screenshot code from a per-monitor dpi aware process.

Upvotes: 1

Related Questions