Detect HDPI support (Windows)

I search hard (and probably not hard enough). But how can I detect that a system has HDPI support or not?

For macOS this is easy, but I cannot find a solid way for Windows.
Xscale/Yscale do not help here, I guess.

Doesn’T screen class have a property ScaleFactor to check?

Sadly not (on Windows). Well, it doesn’t work here.

Edit : ScaleFactor only returns the screen scale. For example 100% → 1, 120% → 1.25, …
This has nothing to do with the screen is HDPi or not.

This probably calls for a declare. @JulianS may be able to help.

Could you clarify what you want to know here?

Is there a display connected that can scale?
Is the display/app currently scaled?
or something else?

I just want to know if the users display is HDPi or not.

If ScaleFactor > 1 maybe?

1 Like

If what Christian suggests isn’t working and you aren’t using a VM, then file a bug report.

You have turned on “Supports HI-DPI” in Build Settings>Shared?

As Christian said, what does Window.ScaleFactor report when you are at 125% scaling in windows?

Ask the user to measure their screen, then ask him to search in the device manual its native resolution. That way you can calculate if it is a real HDPi device or if is only being scaled. However, someone could have a real HDPi device and use it at 100% scaling behaving like a Non HDPi…

Maybe you need our WindowsDisplayMBS class?

There we got physical size of display as well as log pixel ratio.

On a HDPi monitor it says 1.25
On a non-hdpi monitor it also returns 1.25
So that’s no way to check what display/monitor is used.

Oh now you’ve got me curious why it matters if the display is HiDPI when the ScaleFactor is telling you to draw at a certain scale. Sorry I misunderstood your need!

At what point does a monitor become HIDPI?

With my Apple Desktop display (which is HDPi) or my Ilyama HD (1080HD) the scalefactor always returns 1.25 when setting the Windows scale to 125%
Same when I set it 100%. Then both return 1
For 150% it returns hence … 1.5

I’m not sure what you want it to say and when you want it to say it.

A 4k 32" monitor at native res is 3840x2160, with it set to 200% scaling in windows (2.0 scalefactor in xojo) its nice and smooth. However I then only get 1080p’s “worth” of desktop space as everything is twice the size but you can’t make out the pixels.

You can also put an apple 5k “hidpi” monitor in native rez at which point I would no longer class it as hidpi, but again you could turn on scaling and have nice smooth text etc. Is there some arbitrary flag on the monitor that just reports back to macos that it can scale to something that looks nice and smooth?

You 1080 Iiyama could go to 200% and you would end up with a nicer looking 960x540 equivalent screen but it would be “hidpi” for 960x540. Of course if its a 79" screen then it wont be all that good looking unless you stand 10 foot away from it. It’s all relative.

Does apple have a set of numbers that quantify their “hidpi”, like certain ppi which you are looking for in windows because I don’t think windows has gone down the marketing route of creating something akin to “retina”.

This will return the DPI of the display that the window is currently on, if that helps?

Declare Function GetDpiForWindow Lib "User32.dll" (hwnd As Ptr) As UInt32
Dim dpi As UInt32 = GetDpiForWindow(Self.Handle)

Perfect, exactly what I needed!
Thank you Julian

1 Like

Does GetDpiForWindow() return different values than Xojo’s functions?