This probably an easy one and I’m just having a moment.
Is there a way to detect if you application is running on a machine with a HiDPI display? I thought about using the Canvas ScaleFactor property or ScaleFactorChanged event without luck.
My old 2013 27" iMac doesn’t have a Retina display but I got a 28" HiDPI display for my new Mac mini and I can certainly see that my app is using the hi-res images on my Canvas Buttons.
Would be nice to know though so I could do some programatic changes at some point…
Does DesktopDisplay.ScaleFactor get you what you want?
Possibly, on my HiDPI display if gives me a value of 2, so I’m assuming a non HiDPI display would have a value of 0.
I can see that my app is using the 3 x Images on the buttons so this makes sense…
Using PDFs is much easier than using images in 1x and 2x. But your app isn’t using the 3x images for desktop.
Why do you want to know this, just for curiosity sake or are you planning to draw different graphics for different resolutions?
The Apple recommend way is to use API that Xojo doesn’t expose and to do this for each control.
It is possible to have a window ride multiple displays at which point the window adopts the highest resolution, but each control may not.
However if you stick to using points instead of pixels and standard functionality, the macOS will handle this for you.
This is a scaling factor, so a normal screen would be 1. However do not assume that it will always be 1, 2 or 3. Windows offers intermediate sizes and Apple may also in the future (technically some of their screens are already at intermediate sizes, but they fake with software).
Just for curiosity sake really. I like learning new things and seeing what can be done with them. I use image sets for my canvas buttons and they work great on HiDPI displays. Even better now that I replaced the supplied HDMI cable with a Thunderbolt 4 to DisplayPort cable…
As long as it’s simply curiosity, I just wouldn’t recommend altering the contents of your views based upon the Window’s scale factor.
With some declares you can find out the scale factor that is actually applied to that view.