Resize window but not fullscreen

Hello friends,
Another stupid question from me but how do you size a window keeping the borders, that the top of the window is at the top edge of the screen and the bottom is just above the taskbar?
And if possible for all sizes of screen.

Use some combination of the Screen AvailableTop, AvailableLeft, AvailableHeight and AvailableWidth.

And remember to use the BOUNDS of the window, not the Top, Left, etc as those refer to the content area and omit the borders, title bar, etc.

See this forum post for more information.

1 Like

Argh, the links no longer exist.
Yes Tim I have tried with all of that properties but I have always to cheat on the values.

Sorry, didn’t realize they pointed to old documentation.

See the Bounds property of a window. You want to use this instead of just setting the Top, Left, etc as those refer to the CONTENT AREA of the window and exclude things like the border, title bar, toolbar, etc.

So assuming you want the entire window including title bar etc visible, what you want to set is the BOUNDS instead of the Top, Left, etc.

As @Tim_Hare pointed out, you can use things like the Screen’s AvailableXxx properties to determine how to set the BOUNDS of the window.

If you want to consider multi monitor configurations, you need to determine WHICH screen to size it to and place it on. You may find this thread informative for that.

Thanks to both of you, my main problem is the height of the taskbar but I’ll look into the API functions side.

I wrote a cross-platform presentation app, and here are some of “lessons learned” ``` hopefully they can help you. Assuming the following:

Var d As DesktopDisplay = DesktopDisplay.DisplayAt(0) // Change to output display
Var w As DesktopWindow = YourWindow

To fill the screen entirely, use a “Plain Box” window, and then:

w.Top = d.Top
w.Left = d.Left
w.Width = d.Width
w.Height = d.Height

// *IF* the taskbar is still visible, then uncomment following line
// w.FullScreen = True

To fill the screen but still SHOW the taskbar:

w.Top = d.AvailableTop // May not be necessary
w.Left = d.AvailableLeft // May not be necessary
w.Width = d.AvailableWidth // May not be necessary
w.Height = d.AvailableHeight // May not be necessary
var wBounds As New Rect
wBounds.Top = d.AvailableTop
wBounds.Left = d.AvailableLeft
wBounds.Width = d.AvailableWidth
wBounds.Height = d.AvailableHeight
w.Bounds = wBounds

Hopefully, that can help somehow.

One more thing I just remembered … if your intention is to completely fill the screen, you should also set the window’s Menu Bar to “None,” either in the Inspector or at runtime:

w.MenuBar = Nil

Thank you Edward,
Finally I got to something satisfying by showing the menubar and not hiding the taskbar.
I also considered a thin border to clearly delimit the window.

  Dim Border As Integer = 1
  Dim TaskBarHeight As Integer
 
  TaskBarHeight = Screen(0).Height - Screen(0).AvailableHeight
  
  Win_Anafolie.Left = ( Screen(0).Width - Win_Anafolie.Width )\2
  Win_Anafolie.Top = Screen(0).AvailableTop + TaskBarHeight + Border
  Win_Anafolie.Height = Screen(0).AvailableHeight - TaskBarHeight - 2*Border