Window sizing on Windows 11

When resizing a window to full size in Windows 11, it tends to get too big, automatically generating scroll bars to the right and bottom, which I don’t want. Is there a simple way to avoid that ? Tried for hours to figure out what I do wrong. What am I missing ?

You should SHOW what you are talking about.

If you get scroll bars, it means your content is larger than the screen.

1 Like

I know that. I just want to know why it tends to oversize itself without me asking for it.

You could do something like:

dim windowbar as integer =  self.top-self.bounds.Top
self.top = screen(0).AvailableTop + windowbar

self.height = screen(0).AvailableHeight - windowbar

You can set a max set of values here (change 64 to max custom values):
image

A change in code seems a better solution for unknow monitor sizes…

Seems it’s a Windows MDI app and if you restore a window after you’ve maximized it, Windows does not restore the original position.

Apparently, @Claes_Lundstrom has lost interest in his thread…

First of all, thanks for the suggestions! I have been a bit too busy to update on the progress, but I will as soon as I have experimented in full. Your suggestion seemed to have some positive effect, but I have not quite got it right yet

dim windowbar as integer = self.top-self.bounds.Top
self.top = screen(0).AvailableTop + windowbar

self.height = screen(0).AvailableHeight - windowbar

I tried here, and it sizes the window exactly to the vertical space. You would have to adapt that if you need it to fit the width of the screen.

Although according to @Carsten_Belling, if you are doing that in a Windows MDI environment, I don’t know if that will do.

I have yet to figure it out. Worth noting though is that applies to both the horizontals and vertical directions.

Avoid hardcoding things like this because there is people who uses multiple screens, like myself. You need to get it from the context.

Sub Maximized() Handles Maximized
  dim windowbar as integer =  self.top-self.bounds.Top
  self.top = screen(0).AvailableTop + windowbar
  
  self.height = screen(0).AvailableHeight - windowbar
  
  self.left = screen(0).AvailableLeft
  self.width = screen(0).AvailableWidth
End Sub

How would you detect which screen the window is displayed at ?

You need to do some math based on this:

Ulrich wrote extensions to help him with it, but I never tested it, it informs even if a Window is divided between 2 screens and which screen contains the larger part of such window: