Can I get the scaling factor per display?

Windows specific forum
ozzie
Enthusiast
Enthusiast
Posts: 429
Joined: Sun Apr 06, 2008 12:54 pm
Location: Brisbane, Qld, Australia
Contact:

Can I get the scaling factor per display?

Post by ozzie »

It would be really helpful if I could find out the display scaling factor for each connected display. Calculating this for the primary display is easy enough, as shown in this code:

Code: Select all

ExamineDesktops()
myDesktopWidth = DesktopWidth(0)
myDesktopHeight = DesktopHeight(0)
Debug "myDesktopWidth=" + myDesktopWidth + ", myDesktopHeight=" + myDesktopHeight
myHorzRes = GetDeviceCaps_(GetDC_(GetDesktopWindow_()), #HORZRES)
myVertRes = GetDeviceCaps_(GetDC_(GetDesktopWindow_()), #VERTRES)
Debug "myHorzRes=" + myHorzRes + ", myVertRes=" + myVertRes
myDisplayScaling = Round(myDesktopWidth * 100 / myHorzRes, #PB_Round_Nearest)
Debug "myDisplayScaling=" + myDisplayScaling + "%"
which correctly returns this:

Code: Select all

[15:01:43] myDesktopWidth=1366, myDesktopHeight=768
[15:01:43] myHorzRes=1093, myVertRes=614
[15:01:43] myDisplayScaling=125%
However, my second monitor has a display size of 3840x2160 with a display scaling set to 175%. I can get the display size using DesktopWidth(1) and DesktopHeight(1), but I can't find a way to determine the 'horizontal resolution' of a display other than the primary display. Any suggestions?
GenRabbit
Enthusiast
Enthusiast
Posts: 118
Joined: Wed Dec 31, 2014 5:41 pm

Re: Can I get the scaling factor per display?

Post by GenRabbit »

Have you checked out GetScaleFactorForMonitor?

I think thats what you are after. But I do not know how to use it.
ozzie
Enthusiast
Enthusiast
Posts: 429
Joined: Sun Apr 06, 2008 12:54 pm
Location: Brisbane, Qld, Australia
Contact:

Re: Can I get the scaling factor per display?

Post by ozzie »

Thanks for that. I'll see if I can work out what I need using GetScaleFactorForMonitor.
Post Reply