force dialog box to display on main screen

My app uses two displays (screen(0) and screen(1)). Screen(0) is the main screen and has the menubar. I have configured screen(1) for no menubar. My app starts by displaying a window in screen(0) and then displaying a window in screen(1).
The app then sits waiting for the user to do something.
If the user then selects from the menubar, an item that triggers an OpenDialog command, the Open-file dialog box appears on screen(1).
How do I force the dialog box to display in screen(0) (i.e., the main screen)?
Thank you in advance for any suggestions/input.

FWIW, I notice that when I use a keyboard shortcut to display the launchpad, that it also shows up on the second display and not the main display

If your app window is active on screen(1) the OS has determined that was the last active screen, and your dialogs are going to open there. I’m not entirely sure you’re going to be able to control which screen the dialog opens on short of popping a new window on the main screen just before you open the dialog.

I tried that. I have a dummy window that I show and force onto the Main Screen, which is the location of the MainWindow.
I then close the window.
That did not force the app back to Screen(0).

dummyWindow.showWithin(MainWindow)
dummyWindow.close

The app did perform the way I want it to if I first click on the MainWindow to bring it to the front. So I think what Ian really asking for is how can I bring the MainWindow to the front via code.
I saw something in the forum regarding bringing a window to the front, but I couldn’t get the solution suggested by Kem Tekinay to work (Pasted below)
[i]Kem Tekinay 20 Mar 2014 Alpha Testers, Beta Testers, Xojo Pro New York
It took a little looking around, but I found it in MacOSLib. Here is the code with that package installed:

dim nsw as NSWindow = windowToActivate

dim cntrl as new NSWindowController( nsw )
cntrl.ShowWindow
NSApplication.App.Activate( true )
Otherwise, look at the declares behind those calls.[/i]

Other solutions involve a third party MBS solution

The simplest way is to use a window instead of the standard dialog, so you can decide where it goes. Not very difficult to do.

Just look at the coordinates of Screen(0).Left, Screen(0).Top, Scren(0).Width and Screen(0).Height, and place your home made dialog in there.

There is a declare to bring an app to front posted by Axel Schneider here :
https://forum.xojo.com/14202-drag-border-vs-focusring-visual-cues-and-drop-file-selected/0 (4th post).

I have been using for myself, and it works great.

Michel
I don’t really want to construct a window that will look like a standard dialog and I was unable to follow the solution posted by Axel Schneider.
I tried call a method that did this:
Declare Sub makeKeyAndOrderFront Lib “Cocoa” Selector “makeKeyAndOrderFront:” (NSWindow as Ptr)
makeKeyAndOrderFront(Ptr(self.handle))

where, self refers to the window I want to bring to the front.
I think makeKeyAndOrderFront is the sub I want, but I don’t think I am using it correctly. I am a bit of a novice in dealing with the Cocoa library and declare statements.
Any advice?
Thanks

I’m not sure makeKeyAndOrderFront is going to work for you.

This SO thread says you actually have to subclass NSOpenPanel to override it’s positioning:
http://stackoverflow.com/a/8581398

I don’t know if I’ve ever seen a declare for subclassing a Cocoa control o.O
Mayhaps Christian can work something up in MBS for you?

Use Left & Top & position it however you want ?
Why aren’t you just calculating left & top so they’re on screen(0) and then show the thing ?
They’re settable property values

Oh ■■■■, always forget about OpenDialog.

setting
dlg.left=screen(0).AvailableLeft
still brings up the dialog box in screen(1)
Is there a bug with OpenDialog?

What is the full code ?

BTW : please click the “Code” icon <[>] above the forum editor before entering code, so it is more legible.

I am using the workaround:

dlg.ShowModalWithin(MainWindow)

instead of

dlg.ShowModal()

which will display the OpenDialog as a sheet window within my MainWindow. I think I can live with this as MainWindow is always located on Screen(0) and the user will not need to move the OpenDialog around

Indeed it seems there is no way to set the position of the dialog with the left property.

You could file a bug report.