Window Placement - Clarification Needed

Placement can take on the following values:

Value Description
0 Default
1 Parent Window
2 Main Screen
3 Parent Window Screen
4 Stagger

What exactly do these do? (I’ve tried all 5 and can’t really see a difference.

(running in Windows)

If you have several screens they make a difference
On single screen systems there’s almost no difference

Off the top of my head
0 Default - whatever the OS would normally do (which may be to stagger new windows in an app)
1 Parent Window - on the parent window if you have one window open another
2 Main Screen - on the primary or main screen in a multi screen set up
3 Parent Window Screen - on the same screen as the parent window in a multi screen set up
4 Stagger - stagger new windows in an app

Really Language Reference is very poor about this window property.
I want to open a window in a particular screen (multiple screens) and I have found no help at all.
This window is not opened by another window but by a method, so there is no parent window.
Can I have some help?
Thanks.

[quote=67862:@Ramon SASTRE]I want to open a window in a particular screen (multiple screens) and I have found no help at all.
This window is not opened by another window but by a method, so there is no parent window.
Can I have some help? [/quote]

In a system with 2 x screens I found that this worked in the window Open event to place the window on one screen or the other…

if myScreen = 0 then //- Centralise on 1st screen... me.left = ((screen(0).width - me.width) / 2) me.top = ((screen(0).height - me.height) / 2) else //- Centralise on 2nd screen... me.left = screen(0).width + ((screen(1).width - me.width) / 2) me.top = ((screen(1).height - me.height) / 2) end if

This was on MS.windows, with 2nd screen laid out to right of main screen under display settings.

Thanks Chris, but finally I found the error, and as it happens many times it was MY error, not Xojo’s.
I had used both Open and Activate events (it is an old project and I didn’t remember I was using Activate), so everything I was writing in Open was changed silently by Activate.
Now it works perfectly in any screen.

So in order to find out which screen a window resides on I have to check if its left position goes beyond screen(0).width? Or is there any other way like a window.isonscreen property?

IsOnScreen would have to try & figure out what YOU intend the behavior to be

Say you want the top left to determine what screen its on

But I want to have it be determined by the percentage of the window that is on which screen (you’ve dragged the window to be partially on each of two screens)

[quote=69550:@Norman Palardy]IsOnScreen would have to try & figure out what YOU intend the behavior to be

Say you want the top left to determine what screen its on

But I want to have it be determined by the percentage of the window that is on which screen (you’ve dragged the window to be partially on each of two screens)[/quote]

While this can’t be done in Mavericks, it’s still possible in Windows and Linux (and OS X pre-Mavericks).

What is currently the best practice to put windows where they should be? Is “screen” really a useless property and only coordinates make sense?

Coordinates only seem not to work – at least under OS X. I have a window which position I grab and save on its cancel close event. When I try to open it again by that positions (without the use of screen())– and they were on the second screen –, the window is drawn on screen 0 with its positions way out of the screen’s limits.

On windows ( I’ve not use this on other platforms )…

screen has properties which can be useful in placement, the availablexxx ones tell you what area there is, minus stuff like taskbar, so you can decide which screen to pace a window on.

In my main setup I have 3 screens, all different sizes and only the first has .top=0 … you can place sreeens in odd layouts with windows !

It’s the same on OS X.
But thanks for all your clarifications. I found this helpful to determine if a saved window position is at least with one pixel one a visible screen – screen settings may change and therefore absolute positions may not be available anymore.
If -1 is returned I reposition the newly drawn window, else I know why screen it’s on – at least for a part, not weighted like Norman asked for. But that‘s enough for my purpose.

[code]Function IsInScreen(extends w as window) As integer
dim x as integer = w.Left
dim y as integer= w.top
for q as integer = 0 to ScreenCount -1
if (x >= Screen(q).Left and x <= screen(q).left + screen(q).Width) and( y >= Screen(q).top and y <= Screen(q).top + Screen(q).Height) then
return q
end if
next
return -1

End Function[/code]

sorry for all the typos – partly thanks to a spellchecker running wild. I really miss an edit option.

[quote=69596:@Chris Carter]
In my main setup I have 3 screens, all different sizes and only the first has .top=0 … you can place sreeens in odd layouts with windows ![/quote]
Oh you can do this on OS X as well
Have been able to do this on Mac OS going back as far as I can remember (first mac I had at work was a IIfx with 3 x 21" monitors - in 1992)
You can end up with it being possible to place one windows across 3 screens quite easily when you arrange them like

Is there a way to do this with dialogs vs. windows?

You could also create ur own dialog using windows

Yes I realize that but then they look “non standard”. Does anyone know how to get them to use the same icons the system would use for a dialog?