Windows opening on wrong monitor

On Windows customer has 3 monitors. Drags our app after open to 2nd monitor.

When he opens a new window it opens on the main monitor not the one where the main window is.

How do I get the new windows to keep from going to the main monitor?

Also, my File Open or New dialog and other dialogs on Windows show up in the far upper left. They are set to “Default” placement.
Is that correct or should the popup in the middle of the main window?? For large monitors it’s odd that they appear
so far in the upper left.

I would like to have this one to be improved too, but I see it like this everywhere. Contact bill@microsoft.com

I really wish these computers with front facing cameras would just use face detection to know which monitor I’m friggin looking at!

Shouldn’t be rocketscience.

There is not a way to tell a new pop up to “center on the main window” … and would that keep it on the same monitor?

I don’t have a 2 monitor system or I’d just do some experimentation.

This is what I use to center a window on a given screen:

[code]
Sub ShowCentered(Win As Window, ScreenNumber As Integer = 0)
’ Shows the passed window centered on the specified Screen.

Dim X, Y As Integer
X = (0.5 * Screen(ScreenNumber).Width) - (0.5 * Win.Width)
Y = (0.5 * Screen(ScreenNumber).Height) - (0.5 * Win.Height)
win.Show
If Screen(ScreenNumber).Top > Screen(0).Height - 1 Then
Y = Y + Screen(ScreenNumber).Height
End If
If Screen(ScreenNumber).Left > Screen(0).Width - 1 Then
X = X + Screen(ScreenNumber).Width
End If
win.Left = X
win.Top = Y
End Sub[/code]

And to calculate which screen a window is on:

[code]
Function ScreenFromXY(X As Integer, Y As Integer) As Integer
Dim rect As New REALbasic.Rect
Dim pt As New REALbasic.Point
pt.X = X
pt.Y = Y
For i As Integer = 0 To ScreenCount - 1
rect.Top = Screen(i).Top
rect.Left = Screen(i).Left
rect.Width = Screen(i).Width
rect.Height = Screen(i).Height
If rect.Contains(pt) Then
Return i
End If
Next

Return -1
End Function[/code]

e.g.

Dim n As Integer = ScreenFromXY(Parent.Left, Parent.Top) ShowCentered(ChildWindow, n)

THanks a bunch!

Again since I can’t test it with multiple monitors… does this code work for both Mac and Windows?
(I don’t even know if macs support multiple monitors… sad I know)

Do either MS User Guidelines or Apple Human Interface Guidelines say that dialogs can or cannot be centered vs. some other location?

I did try to set one dialog to parent window thinking it would center in the middle or up top of its parent but still showed up to the left.

It should work on all supported platforms, but I’ve only tested Windows and Linux.

What about Behavior --> Placement (select the window and search at the bottom in the right pane: properties) ?

I am mixing questions I guess… the one about not having dialogs pop up in the upper left corner instead of near the main window… I tried changing the Placement to different options and did not see a change. I will read up on that.

As for multiple monitors, from feedback from my client and from the others on this thread it defaults back to the main monitor unless you do something about it and the Placement doesn’t help?? I’m assuming that’s why @Andrew Lambert posted the code that he did…

Behavior --> Placement --> Parent WIndow Screen ?
AFAIK, it will place the newly opened window to the screen (monitor) where an already opened window resides.

So, if you have a window in Monitor #3, the window that have this setting will be opened in Monitor #3.

Am I right ?

The documentation says this:
Placement can take on the following values:
Value Description
0 Default
1 Parent Window
2 Main Screen
3 Parent Window Screen
4 Stagger

But it doesn’t define what those mean at all. I could easily test them with trial and error but I don’t have a multi monitor system.

look at Normans Post

https://forum.xojo.com/conversation/post/51863

Just an unsorted thought: Open new windows into the screen where the mouse is

1 Like

I tested Default and Parent Window placements in both Windows and Sierra.

I have 2 monitors and I moved them around:
Primary left, Secondary right
Primary right, Secondary left
Primary bottom, Secondary top

Both placement behavior open Window2 inside the Main Window, where ever the Main Window is. The only different is the position of Window2.

Thanks for trying it. Which version of Windows did you test as your screenshots show Mac.

[quote=314703:@Axel Schneider]look at Normans Post

https://forum.xojo.com/conversation/post/51863 [/quote]

Thanks a lot of info on there. Still seems to be a fairly confusing subject.

I tested on Win7 x64 and Win10 x64. Same behavior on all three OSes. That’s why I show only the Mac. Here are screenshots for Win10:

You’re cool… thanks for testing that. Great info for everyone to have.

Quick related question… what “window Type” did you use? Document, Modal, etc.

Also is there a way to set the parent Window type placement for dialogs?

I have file new and open popping up in the far upper left of my Windows display.