From where do I control a multi window app?


I’m new to Xojo and I want to write an application that has multiple windows (probably about 8). I’m used to Visual Studio where I can elect to control my app from a form or from a standard module using a main procedure. The later is what I would like to do with my Xojo app, but I can’t see how to do it. My first window in my app will be a login window and it seems odd to control the whole app from that window. Can anyone tell me how I can control my app from outside of a window?

global Module, Methods, Properties

The core object of a desktop app is not he first window but the app object. That’s a good place for global properties and methods as well as a global menu handler and probably a good place for managing your app too.

The concept of central control of an event driven process is a bit outdated. Your app should respond to user activity, not try to drive it. Things will be much easier if you adjust your mindset.

Thanks for your replies. Sorry I’m so green at this.

The first thing that is to happen when my app opens is for a login window to show and then, when the user has logged in, that window is closed and a main menu window appears. That menu has about four options, each requiring a window of its own.

I just went to the app object and created a method, called it Main and wrote some code in it that I was hoping would be read as soon as the app opened, but it didn’t read that code. What am I doing wrong, please?

Show us the codes, pleaze.

If you know a bit about object oriented programming check out MVC. If you don’t know about OOP check it out, too :slight_smile: .

Because you came from Visual Studio.

The Xojo Desktop app doesnt have a Main() as such.
The closest is the Open() event.

Your app object should be given an Open() event (use Add Event Handler instead of Add Method)
What is in the Open() event will fire when the app starts, and when it completes, the application should /could end

But in that event you might create a login window and display it modally.

That window may create another such window, and that will stay on screen waiting for interaction until closed.

Ah, thanks Jeff. I’ll give that a go tonight. That makes sense to me.

And, Beatrix, I am familiar with OOP. Is there a website you’d recommend re MVC?

Thanks, all. Really appreciate your help.

What you need is not so much OOP or MVC, it’s event-driven. Everything in your Xojo program happens in response to an event. I would advise against trying to do too much in any one event, such as app.Open. When your program starts up, you can do some setup and housekeeping in app.Open and Window.Open. Your first window will be opened for you, and its Open event will fire. That could be your login window. When the user finishes logging in, you would close the login window and open your main window. When the user selects a menu item, an event will fire. In that event, open the appropriate window and close or hide the main one, if desired. When the user closes that window, the Close event fires. Decide what to do in that event, such as showing the main window again. Try to avoid one monolithic method that tries to do everything. Break it down and spread it out over the events of the program. It really allows you to focus and makes everything much, much easier.

Thanks, Tim. I get it. That sounds relatively easy to implement. I really appreciate your effort to make that clear.