Window1.Bounds

The snipped below crash on an OutOfBoundsException here:

Dim myBounds As New Realbasic.Rect myBounds.Left = 100 myBounds.Top = Screen(0).AvailableTop Self.Bounds = myBounds

I put the code in the Window1.Open Event.

I changed Screen(0).AvailableTop by 100 (for testing) with the same trouble.

Do you get that too ?

El Capitan .6 / Xojo 2016.4.1 running in the IDE.

You aren’t setting the width and height properties of that Rect

Thank you for your answer, but I do not understand it.

The code comes from the docs / I set both values to 100 just in case, but I get the exception.

Also, I do not say that I only have one screen (monitor) actually, connected to my MacBook Pro.

At last, this crash too in Windows XP in both the 2015r1 generated application and Xojo 2013r4.1 (last IDE runing on Windows XP).
I ran Windows XP in VirtualBox / El Capitan .6.

This is the example code at http://documentation.xojo.com/index.php/Window.Bounds

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

You forgot two important lines…

No, I forgot nothing. I took the example in Xojo 2016r4.1 language reference: Window.Top.

Your code above works fine. Thank you.

Dim myBounds As New Realbasic.Rect myBounds.Left = Screen(0).Width - (Me.Width + 2) myBounds.Top = Screen(0).AvailableTop // Screen(0).Height - (Me.Height + 2) myBounds.Height = Self.Height myBounds.Width = Self.Width Self.Bounds = myBounds
I get the window at Right/top of the window: nice !

I think I know why I was reluctent to use Window.Bounds recently.

If you look at your original post, you will see that the code snippet is missing the “myBounds.Height” and “myBounds.Width” lines… Easy mistake to make… Been there, done that, just happy that it is working for you now…

Let me rephrase it:

THE SNIPPED COMES FROM THE XOJO DOCUMENTATON.

Thank you for the help.

[quote=306667:@Emile Schwarz]

Dim myBounds As New Realbasic.Rect myBounds.Left = 100 myBounds.Top = Screen(0).AvailableTop Self.Bounds = myBounds[/quote]

[quote=306682:@Emile Schwarz]

Dim myBounds As New Realbasic.Rect myBounds.Left = Screen(0).Width - (Me.Width + 2) myBounds.Top = Screen(0).AvailableTop // Screen(0).Height - (Me.Height + 2) myBounds.Height = Self.Height myBounds.Width = Self.Width Self.Bounds = myBounds[/quote]

While the code snippet might have come from the documentation, the two code snippets, quoted above, are not identical… That is all we are saying… The first snippet, in your original post, is missing the .Width and .Height properties and that is what was causing the original error… The second snippet you posted has those properties and is working for you…

[quote=306744:@Emile Schwarz]Let me rephrase it:

THE SNIPPED COMES FROM THE XOJO DOCUMENTATON.

Thank you for the help.[/quote]

http://documentation.xojo.com/index.php/Window.Bounds - hasnt changed since Feb 2015 and includes top left width & height

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

Norman,

get an eye in Xojo 2016 4.1, type Window.Top and watch carefully the example. That is where I came from (in fact, I started at the same doc with Xojo 2015r1). I checked 2016r4.1 before asking here.

Why looking at Window.Top ? Just because I wanted to place the window at the top of the screen. Also, the word Bounds escape to my mind at the moment.

All:
you were right.

All I wanted to say was… I falled in a trap following the documentation.

Also: It is not an easy task to maintain a documentation 100% correct. But as I wrote elsewhere, I dance on this waltz for 20 years (in may I think). It is a bit boring to always fall into traps (worst: sometimes I fall more than once in the same trap).

In REALbasic 1.0, the documentation was small enough for me to print it and add data to pages, corrections, etc. It is not possible anymore to do that.

I see the online docs were updated - today :slight_smile:

Yeah, the Window.Top sample code was not right, as Emile noticed. I corrected it earlier today.