Window.Bounds crashes

From the documentation: Window.Bounds entry:

Example #2:

Dim myBounds As New Realbasic.Rect myBounds.Left = 100 myBounds.Top = 100 Self.Bounds = myBounds

Crash with Xojo 2014r3.1 and 3.2.

A non crashing code is below:

[code] Dim myBounds As New Realbasic.Rect

// Fill the properties
myBounds.Left = 100
myBounds.Top = 100
myBounds.Height = Self.Height
myBounds.Width = Self.Width

// Apply the new Bounds
Self.Bounds = myBounds[/code]

And, no explanation to how to place a window just below the MenuBar. Someone in this list gaves me the last time I wanted to use Window.Bounds.

It was about the use of Screen(0).AvailableHeight and Screen(0).Height, so replace the line myBounds.Top = 100 by:

myBounds.Top = Screen(0).Height - Screen(0).AvailableHeight

This works fine on OS X 10.10.2 (Yosemite). Not (yet) tested on Windows 8.1.

Thank you, Emile. You’re right, setting a rect with 0 width and height isn’t good for a window.
Did you post a feedback report so the line(s)

winBounds = Self.Bounds
or your

[quote] myBounds.Height = Self.Height
myBounds.Width = Self.Width
[/quote]
get added to the LR example?

Thanks again!

Hi Ulrich,

Paul have made the changes to avoid the crash, but do not add the other important addition to do: make the code example usefull (if I am correct):

myBounds.Top = Screen(0).Height - Screen(0).AvailableHeight

Check here.

About my Feedback reports.
I will gave only one hint: a bug report written on mid-april 2013 was checked in January 2015. It was about my inability to install a valid, just paid, Xojo’s license to be able to build an application.

Fortunately, and “with a little help from my friends”, I was able to do that in late April 2013.

[quote=165107:@Emile Schwarz]About my Feedback reports.
I will gave only one hint: a bug report written on mid-april 2013 was checked in January 2015. It was about my inability to install a valid, just paid, Xojo’s license to be able to build an application.[/quote]
Mentioning things in the forum is great and all, but there is no guarantee we will actually see them.

If you truly care about something in Xojo getting fixed or changed, please try to get it into Feedback.

[quote=165107:@Emile Schwarz]but do not add the other important addition to do: make the code example usefull (if I am correct):

myBounds.Top = Screen(0).Height - Screen(0).AvailableHeight[/quote]
This code does not do what you expect if the Dock is positioned at the bottom of the screen.

Thank you for the answer.

The Dock here is always invisible. Chances for me to fall under that were very very thin.

Now the question is: “How do I put a window just below (vertically) the MenuBar ?”

For a single screen…

[code] dim b As REALbasic.Rect = MainWindow.Bounds

b.Top = Screen(0).AvailableTop

MainWindow.Bounds = b[/code]

note that

MainWindow.Bounds.Top = Screen(0).AvailableTop

doesn’t work

This is in the documentation.

For the previous advice, I will check later.

[quote=165421:@Will Shank]note that

MainWindow.Bounds.Top = Screen(0).AvailableTop

doesn’t work[/quote]

Window.Open

  dim mybounds as new REALbasic.Rect
  mybounds.width = 550
  mybounds.height = 340
  mybounds.Left = 0
  mybounds.Top = 0 + Screen(0).AvailableTop
  
  self.Bounds = mybounds

What I meant to point out is that an assignment like this…

…doesn’t actually set/change/apply a new Top value. The Window doesn’t move. You have to assign a Rect to the Bounds property for the Window to be updated.

This is in the documentation.

This seems to work with the Dock Visible and Invisible on OS X.

Surprised.