Resolution Question

Client is using Windows 8.1. Text size is set to Medium. It’s all the defaults I believe.

Under Make text and other Items larger… Click on Let me choose one scaling level for all my displays. What is the DPI set to? I can’t say I know what your issue is , but in general, this is where I have scaling / display issues with Windows.

OK. I just had him send me a new screen shot with some additional text I added to capture and report his height and available height as reported by the framework. It’s definitely a scaling issue as while there are 1080 pixels, his height is being reported as 864 pixels with 813 as the available height. So the framework is reporting the correct values. Now to figure out where my bug is… :frowning:

[quote=178046:@Jon Ogden]OK. Here’s the image. So the vertical resolution in pixels is 1080. The size of the window is being reported on the window as 813.

You tell me what’s going on… :\

[/quote]

I think I got it : I created a sample project with a 813 pixels high window, and ran the project under a scaling of middle. I get the same phenomenon.

I maximized the window under all availabale scales. Here is the result for window size :
Smaller : 1920x997
Middle : 1536x781
Large : 1280x637

Availablewidth and Availableheight do report proportional values :
Smaller : 1920x1040
Middle : 1536x824
Large : 1280x680

So in effect Xojo does report an accurate available width, you just haev to adapt your window to the user setting. You do not have a bug per se. Just the need to manage a smaller screen size.

Yes, Xojo is reporting the virtual size of the screen. It’s a bug because my code is looking for the wrong size. I am looking for anything with an available height of less than 813 which is my window size. But I’m not taking the window frame or menubar into account. So that is a bug! :slight_smile:

Well, now you spotted it :slight_smile:

I confirm what I said earlier:

your screen shot (done using the Windows “immediate” keyboard shortcut who put the image in the clipboard, not the other one) have a dpi of 120 (unlike the Windows “traditional” 96 dpi.

So, some applications will display it at 96 dpi (some others at 72 dpi / OS X ?) and so the image will appears in a larger area.

Did you say HiDPI ?

OK. So I think I have the “problem” figured out regardless of wether it is 96 DPI, 120 DPI, etc. The framework is reporting the correct values based on the user’s setting.

But this is what I have an issue with that I don’t understand:

Screen.AvailableHeight is defined as:

So my reading of that is that the taskbar height is taken into account when calculating available height. But it isn’t. In my code, I have the following:

  If Self.GetScreen.AvailableHeight < 813 Then
    SetWindowSizes(True)
    GetTopAndLeft(Self)
    Self.DetermineWindowHeight(me.Height)
  Else
    SetWindowSizes
  End If

Self.GetScreen is a method that returns the correct screen for the window.

So my window is 813 pixels high. If the AvailableHeight is less than that, then, I basically adjust my window size to whatever is the full size of that screen.

But as can be seen in the images below, my window is reporting as being 813 pixels high with the available height as 826 yet the window is still extending beyond the bottom of the screen.

What am I getting wrong?

Surely this 813 is not taking into account the window title and menubar and the frame size ?

Well, According to the Xojo Docs on AvailableHeight:

So you would think the menubar would be included in that…

Still, I have the following code that I use to calculate the maximum window size. So I’m not sure what I am doing wrong.

Oh wait - I’m only calling this method to set the size if my available height is than 813…So maybe that’s what I am doing wrong…

[code]
Declare Sub GetClientRect Lib “User32” ( handle as Integer, r as Ptr )
Declare Function GetSystemMetrics Lib “User32” ( index as Integer ) as Integer

Const SM_CXFRAME = 32
Const SM_CYFRAME = 33
Const SM_CYMENU = 15
Const SM_CYCAPTION = 4

Dim mb as new MemoryBlock( 16 )
GetClientRect( App.MDIWindow.Handle, mb )

  w.Height = w.GetScreen.AvailableHeight - w.Top - GetSystemMetrics( SM_CYFRAME )

[code]

That menubar is the main window one, usually at the bottom of the screen - I was referring to the application window, where xojo reports height as the internal height, not including the frame.

OK. The documentation isn’t clear… So does GetSystemMetric(33) return just the width of the window frame and then I need to call GetSystemMetrics(15) to get the menu height?

Then I have all I need - right? Would be nice if Xojo provided those values natively… :\

I see some mention that this may not be enough in some cases… in this webpage

So it looks like you need: CY_MENU, CY_CAPTION and CY_FRAME

To get the actual size of your window including the frame and menubar use Window.Bounds

Window.Height and Window.Width only report the size of the content area.

  • Karen

Oh - is it that easy? I don’t have to use all the Windows API declares?

That’s awesome. Never knew about that…

[quote=178264:@Jon Ogden]Oh - is it that easy? I don’t have to use all the Windows API declares?

That’s awesome. Never knew about that…[/quote]

I never use any winapi declare for windows size. That probably explains why I never had any trouble :wink:

Learn something new every day. Checking this way:


If self.GetScreen.AvailableHeight < self.Bounds.Height Then
//code
End If

Works great…

I solved it. All is good…

And here’s why I didn’t take the frame size into account at first.

Monitor vertical resolutions are typically in the following steps:

720
900
1080
etc.

So if a monitor is 900, my window fits fine. The next step down is 720 which is way less than my window height and would trigger my code to resize the window. I never considered the fact that there might be a screen with vertical resolution of 864 pixels! But if they got scaling going on which this guys does, then this happens.

The nice part about running windows in a Parallels VM is that I can test with whatever vertical resolution I want! :slight_smile:

So I just tested this out and it works great…

Yup - and also using a VM is a common way to see really weird screen sizes as well…