Posizion windows 0,0

Hello group, I have a MAIN with title bar and Menu, if I position it in X=0 and Y=0, I no longer see the title bar and I no longer see the menu. How do you position the entire window at the top left?
I write:

Self.Left = Screen(0).AvailableLeft
Self.Top = Screen(0).AvailableTop +50

+50 it is the movement required to display the bar and menu

See Menubar Height

1 Like

use bounds propertie from window
https://documentation.xojo.com/api/user_interface/desktop/desktopwindow.html#desktopwindow-bounds

1 Like
Dim Difference as integer
Difference=self.Bounds.Top - self.top

Not work … Difference is -31, not good. I need ± 50. Where am I going wrong?

That’s telling you what the difference between the bounds and the content area is. In other words, that’s the height of the Title Bar. As far as I can tell, 50 is a magic number you chose. Perhaps at random?

If you set the Window.Bounds.Top to DesktopDisplay.AvailableTop the Window will be correctly positioned under the Menu Bar. Is that not what you are trying to do?

Please review the thread TomE linked.

Self.top=0 I don’t see the title and the menu

Self.Top = (Screen(0).AvailableTop-self.Bounds.Top) i see a menu but not a title

Self.Top = Screen(0).AvailableTop +50 with my magic number, i see Tile and Menu.

I would like to set some parameters without having to think that I just got lucky by typing +50, but I can’t figure out how to display the entire window with the title and menu.

Tim gaves you THE solution. Please follow his advice.

1 Like

Position the window with Window.Bounds and there should be no calculation necessary. The documentation for Window.Top says exactly what I have said.

A code example lives in the thread TomE (and myself) linked.

1 Like

xojo have a outer rectangle and the inner rectangle.
create a rectangle and use Self.Bounds =

1 Like

Back in the day we did have to use the Magic Number 50. Much trial and error went into that. These days it’s no longer required.

Don’t be offended… but there are some procedures that are difficult for me to understand. So, I followed your advice and tried to set the Bounds property…writing like this:

Var myBounds As New Rect
myBounds.Left = 0
myBounds.Top = 0
myBounds.Height = 1050
myBounds.Width = 405
Self.Bounds = myBounds

Can it go like this?

it need the Screen Available values as example if someone have the taskbar at top or left.
in case the user can use your window and should also see the os components.

you could also try opening the window maximized, at windows os it should use the available desktop space.

Change your code from:

Self.Left = Screen(0).AvailableLeft
Self.Top = Screen(0).AvailableTop +50

to (as Tim posted on the other thread):

var oBounds as Rect = self.Bounds
oBounds.Top = DesktopDisplay.DisplayAt(0).AvailableTop
oBounds.Left = DesktopDisplay.DisplayAt(0).AvailableLeft
self.Bounds = oBounds

Screen is deprecated.

1 Like

An important difference is that this design fetches the existing Bounds from the Window. The width and height don’t need to be hard coded. Meaning if the window size changes the code will not need to be updated.

1 Like

and usually you need to read the data from correct monitor, most people have 2 monitors beside
and possibly not all people have same monitor sizes, or task bar only visible at the primary.

Remember to see the whole picture. OP’s original design was using Screen(0) so there’s no need for us to build an over-engineered demo for anything else.

1 Like