Create/control second window on second screen

I used Real Basic some time ago, and am just starting back up with Xojo. Time to get my brain re-oriented.

The app I want to build will have a setup/control system in a window on screen 0 that controls a movie player in a second window on screen 1.

Is there any sample code hanging around that can show me the basics of instantiating the second window and calling events on the second window?

Thx in advance.

dim w as new Window2 W.yourMethodHere()

Taken from docs window, the code below to set the window size:

Dim myBounds As New Realbasic.Rect myBounds.Left = 100 myBounds.Top = 100 myBounds.Height = Self.Height myBounds.Width = Self.Width Self.Bounds = myBounds

Also, you have to set the window in the “external” monitor (determine where that external screen is, relative to the main window) ?

Thanks Greg/Emile…and how do I force the window to open on the second screen (if it is available)?

check the screen count… and use the SCREEN(1) values in the code Emile posted above

dim w as new Window2 if screenCount > 1 then w.left = screen(1).left + 100 = screen(1).top + 100 W.yourMethodHere()

Thanks all, this is what I have since I want to run the movie full screen on the second screen. I have the movie player object set to auto resize and pinned to all edges of the window. The way i’d like this to work is the main window on screen 0 will control content playback on screen 1 using various buttons on the main window. Does this mean I need to set up the second window on screen 1 within a class (so I can call it from the main window), or just declare the second window as a global so I can reference it from anywhere?

Dim myscreens as Integer
If (myscreens=1) then
MsgBox "You’ve only got one monitor. "
dim w as new MoviePlayWindow
w.left = screen(0).width+1
w.width = screen(1).width = 1
w.height = screen(1).Height
w.FullScreen = true
end if

Thanks for the education!

Make w a global window property in a module.

Sneaking up on it. I created a global property ‘PlayerWindow’ in module ‘PlayerModule’. This code then properly opens the window. (Thanks Michel) The window has an embedded MoviePlayer control called ‘MoviePlayer2’. My thought was I could reference the MP object with a call to the global property, i.e. "PlayerWindow.MoviePlayer2.Speaker = TRUE’ just as I do from a local variable. I tried creating methods in the window to set the MP object property, but I don’t see them as an attribute of the global property. Obviously I’m missing something very basic.

I’ve read through the intro docs.Most of the RealBasic books seem to be pretty dated. Any type of reference book you can recommend that might give me more insight for things like this? Or, are the older books OK even though they’re dated?

Dim myscreens as Integer
If (myscreens=1) then
MsgBox "You’ve only got one monitor. "
dim PlayerWindow as new MoviePlayWindow
PlayerWindow.left = screen(0).width+1
PlayerWindow.width = screen(1).width = 1
PlayerWindow.height = screen(1).Height
PlayerWindow.FullScreen = true
end if

That’s how that works. Check to make sure you have the right scope for everything involved.
Reading your code though, be sure you aren’t creating a new window each time you’re trying to access the original one.

Hard to tell without seeing how you’ve got your project set up.

Edit: I forgot (not immediately on your mind when you think of these things) that to get the controls to show up, the property must be your window subclass and not just Window. See demo project below for example.

Here’s a demo project to show how it can be done:

Fred, as it is posted, your code creates a local variable :

dim PlayerWindow as new MoviePlayWindow

You want to use your module property instead :

PlayerWindow = new MoviePlayWindow

Ok, my proof of concept is almost baked. The essential thing I missed is having the global property type set to the name of my window (I had it as object). As soon as I changed it to MoviePlayWindow I was good to go. So, now the movie opens and plays on the second screen. The difficulty now is that my second screen is big and the movie opens as 1080p (1920x1080) even though the window containing the movie player is full screen an the movie player object is auto resize and pinned to the window extents. Before I open the movie to play, the movie player object fills the screen.

Is there a way to force the movie player object to full screen to match the window? I tried to set the width, but that doesn’t seem to change the object.

Thx for all your help, you’ve been most gracious. Once the proof of concept functions barely, it’s time to start from scratch and build a real program!

OK, got it figured out. I had the MoviePlayer set to ‘auto resize’ thinking that this is what I wanted for the object to resize with the window when it went full screen. However, when the movie opened the opposite happened. The MoviePlayer resized to the default size for the actual movie (less than full screen). As soon as I disabled the auto resize the movie opened at the full extents of the window. Duh!