Display Resolution

On Windows 10. I have one display, resolution is 3840 x 2140. When I do this:

Var c As Integer = DesktopDisplay.DisplayCount
Var h As Integer = DesktopDisplay.DisplayAt(0).Height
Var w As Integer = DesktopDisplay.DisplayAt(0).Width
Var s As Double = DesktopDisplay.DisplayAt(0).ScaleFactor

MessageBox("c: " + Str(c) + " w: " + Str(w) + " h: " + Str(h) + " s: " + Format(s,"###.##"))

I Get this:
I would expect that the scaling should not influence the resolution reported, but it looks like it does (nothing in the docs indicate this that I can see). Interestingly, the 2560 reported x 1.5 = the correct 3840, but this does not work with the width 1400 x 1.5 = 2100, not 2,140.

What am I missing?

image

Here’s my screen properties

but this does not work with the width 1400 x 1.5 = 2100, not 2,140.
(You mean with here)
The Height of 2100, does not include the windows bar, it appears to be the actual you can use, AFAICT.

Is there not an “actualWidth” or “pixelWidth” property?

On 2022r3

@1920x1080 100%
image

@1920x1080 150%
image

edit: Did not apply the Scale :slight_smile:

I appear to be getting the correct numbers

Hi Sam,

You might be thinking of AvailableWidth? Unfortunately, this yields similar result and excludes the height of the taskbar…

AvailableWidth As Integer

The available width (in pixels) of the display, taking into account the taskbar if placed on the left or right of the specified display.

This property is read-only.

Use the DisplayAt method to call AvailableWidth. For example, DisplayAt(0).AvailableWidth returns the available width of the main display.

Hi Daniel,

The .Height property should return the actual height in pixels of the display.

The .AvailableHeight property should return what you are describing; screen res MINUS task bar Height.

In this case I want the display resolution (.Height .Width).

It looks like yours returns correctly, but I do suspect the issue might be related to HIDPI screens.

Makes sense might be related to higher than HD screens. I do not have anything higher than 1920x1080 RN.

Could it be that you have a ScaleX <> ScaleY :thinking:

Try to create a BitmapForCaching and test the ScaleX and ScaleY properties.

I didn’t mean available width, IIRC (on the Mac) there is a way to get the actual pixel dimensions of the panel (including it’s PPI), so I thought there might be something like that in the Xojo framework.

I thought wrong.

I sure wish there was, but I think that is what the display.width and .height is supposed to do. I suspect there is a bug when used on HDPI monitors when scaling is used.

More data for your research:

1 Like