Implicit Window Question (Xojo 2021 R2)

Howdy Xojonauts!

I am new to Xojo… But I am very interested in the cross-platform abilities, so I have taken the plunge…

Would someone please test (and, if possible, explain) the following?

Create a new, empty project.
Rename “Window” to “Main” and Inherit from the Window Class.
In the Inspector under “Behavior”:
set ImplicitInstance to False (Off)
set Visible to False (Off)
In App, add a Property named “StartWindow” with Super of “Main”.
In App, add an Open() event handler.
In the Open() event, add this code:

   StartWindow = New Main
   StartWindow.Show

Run the application.

According to the documentation (http://documentation.xojo.com/index.php/Window.ImplicitInstance) shouldn’t this be generating an error? Why does the window get displayed?

In the App.Open() event, add this code BEFORE StartWindow.Show():

StartWindow.Title = "Hello, world"

Why doesn’t the Title change? What am I not understanding?

In the Main class, add an Open() event handler and add this code to it:
System.DebugLog("Main.Open()")

Why does Main.Open() get called twice?

I come from a C/C++/C# background where we pass references around and create new windows on the fly all the time. Why is this behavior different?

Thanks for your help!
jdb

I just noticed that two windows (Main) are being created (they were overlapping). One updates with the title change, the other doesn’t. I am too confused… This explains why Main.Open() is called twice, but why are there two instances of Main being created?

Maybe you didn’t change the App Appearance Default Window to None:
image

At least is not in your steps.

AlbertoD, you are a genius! I knew there had to be a simple answer I was overlooking… Thank you for your help!
jdb

1 Like