Screen Top, Left calculations

Since upgrading to XOJO 2016, Screen top, left, width and height are calculated differently if the screen zoom is greater than 100%. If the zoom is set to 100%, everything worked how it did under 2015.

What was the purpose of this change? And can I change it back?

Thanks

This probably has to do with the retina features that were introduced in 2016. IIRC, the units are now measured in points instead of pixels.

I’m not in front of Xojo at the moment or I’d try this myself, but does it make a difference if you toggle the state of the “supports retina/hi-dpi” switch under the Shared Build Settings?

[quote=264699:@Adam Meyer]Since upgrading to XOJO 2016, Screen top, left, width and height are calculated differently if the screen zoom is greater than 100%. If the zoom is set to 100%, everything worked how it did under 2015.

What was the purpose of this change? And can I change it back?

Thanks[/quote]
It might also be helpful to know how it has changed.

Here is the top, left, width and height of the same monitor at 100%: 0 1920 1920 1080, at 125%: 0 1536 1536 864.

I was using the Screen method to get the resolution of the displays. What is the best way to do that now that this doesn’t return the correct values anymore?

Thanks

The values are correct if I turn off the retina/hi-dpi switch. Is it possible to turn it off just for Windows?

You can use this code to find the current scale-factor:

[code]Declare Function GetDC Lib “user32” (hWnd As Ptr) As Ptr
Declare Function GetDeviceCaps Lib “gdi32” _
(hdc As Ptr, nIndex As Integer) As Integer
Declare Sub ReleaseDC Lib “user32” (hWnd As Ptr, hdc As Ptr)

Const LOGPIXELSX = 88
Const LOGPIXELSY = 90

Dim hdc As Ptr = GetDC(Nil)
Dim dpiX As Integer = GetDeviceCaps(hdc, LOGPIXELSX)
Dim dpiY As Integer = GetDeviceCaps(hdc, LOGPIXELSY) ReleaseDC(Nil, hdc)

Dim scaleFactorX As Double = dpiX / 96
Dim scaleFactorY As Double = dpiY / 96
[/code]

If you multiply those scale factors by the values returned by the Screen method that should do the trick whether you’re in high-dpi mode or not.

Certainly
An IDE script like
PropertyValue(“App.SupportsHiDPI”) = “false”
as a prebuild step for Windows should work

Is it not precisely what is available in HiDPI apps since 2016R1 with ScaleFactor ?

Ah! I was unaware of this new method! That’s a better way to go and is probably more optimized.