MainWindow? Is that a class?

I was trying to create an openGL application in Xojo and found the FuildsDemo in the sample code.

There is something I don’t understand and that is, in the FluidField Class there is a Property called ParentWindow.

ParentWindow as MainWindow

There is no MainWindow Class or interface :thinking:
There is am instance of a Window called MainWindow. :face_with_head_bandage: :pleading_face:

What am I missing?

Every window you add is a class and can be addressed just like any other class.

Add a window to your project named MainWindow.
Add a property to MainWindow called count as integer
Add a property to a class, ParentWindow as Window
Set ParentWindow = MainWindow // legal, because MainWindow is a subclass of Window
Try to access ParentWindow.count // fails, Window has no such property
You can access it by casting MainWindow(ParentWindow).count
Change ParentWindow as MainWindow
Try to access ParentWindow.count // success, because it is defined as MainWindow and MainWindow has a count property.

Bottom line, when you add a window to the project, you’re defining a class as well,

1 Like

I would have thought that a class interface at least would have to exist in the project or the definition of the class.
Inst1 as new Window
Inst2 as new Inst1

Here, Window is a Class
Inst1 is a variable.

You could

var Inst1 as new Window
var Inst2 as Window  = Inst1   
// Inst2 and Inst1 both refer to the SAME window, they act like pointers in some ways.
var Inst1 as new Window
var Inst2 as new Window 
// Inst2 and Inst1 both refer to DIFFERENT windows

If you add a public property to Window , called ParentWindow
Then you could

var Inst1 as new Window
var Inst2 as new Window 
Inst2.parentwindow = Inst1
// Now, Inst2 can access any public property of Inst1, using the ParentWindow  variable.