How Do I Determine the Front Most Screen?

Follow-up to
https://forum.xojo.com/36608-force-dialog-box-to-display-on-main-screen/0

I want to open a Window, usually my main app window, in the Front Most Screen, NOT necessarily the “Main” screen.
This is the screen that is Active, that shows an active Apple menu bar, that has the Front Most Window.

How do I get the bounds of the Active, Front Most Screen?

Screen.ScreenAt seem to only allow a Screen.Index of 0, for “Main”, and then whatever other screens/monitors you have.
I have two Screens. Xojo will only allow “0” and “1” as a Screen Index.

In AppleScriptObjective-C and in Keyboard Maestro, I can get the bounds of the ACTIVE Front Most Screen. How do I do it with Xojo?

I still have the above question, but it came up because I need to CENTER my App Window in the Active Front Most Screen.

Just found this solution:
https://forum.xojo.com/52827-centering-a-window/0

[h]Center Window on Front Most Screen[/h]

declare sub NSWindowCenter lib "AppKit" selector "center" ( NSWindowInstance as integer )
NSWindowCenter( me.handle )

[quote=491446:@Jim Underwood]I want to open a Window, usually my main app window, in the Front Most Screen, NOT necessarily the “Main” screen.
This is the screen that is Active, that shows an active Apple menu bar, that has the Front Most Window.

How do I get the bounds of the Active, Front Most Screen?[/quote]
I don’t know if this is quite what you’re looking for, but in this discussion Opening Modal Windows on Second Screen that I initiated a while ago, I provided some example code (& a download) for opening & centering a new Window within the same Screen as the Window that initiates the opening. This is for the case when the Window is not on the “Main” screen, but a secondary screen - and because you may be interacting with that Window, this makes the secondary screen “Active”.

Take a look at the ScreenIndexGet function. Credit goes to @Christian Schmitz & @Michel Bujardet for the code in there.

I hope that helps.

Scott, thank you for the reference. Your thread is very helpful in general, in dealing with windows.
However, if I understand the ScreenIndexGet function, that is getting the screen that the main app window is currently in, correct?

That is helpful, but not exactly what I need.

I need the Active Screen BEFORE the Xojo App window is shown. I want to open the Xojo App Window in the user’s currently Active Screen, where most likely he/she is focused on, expecting the App Window to appear.

So far, using the NSWindowCenter is the only solution I have found, which is, of course, specific to the macOS.

Thanks again for your help.

Hello,

This may give you some hints:
https://forum.xojo.com/58628-best-practice-to-move-a-window-to-another-screen
https://forum.xojo.com/59355-difference-between-the-screen-function-and-nsscreenmbs/0#p482955