Hide a Window only if is Open

Hi! i am using desktop programming and i want to hide a window ONLY and JUST ONLY if is open. i dont know even if that is possible with xojo. When i try to hide it using window.hide or window1.visible=false if the window is not loaded, xojo loads the window and then hide it. i think it occurs because xojo can’t hide a window that is not loaded, so xojo load the window and then hide it. the problem with this scenario is that if i have code into the “open” event it is executed.
my question is… How do i hide a window ONLY if is loaded?
thank a lot!

Turn off ImplicitInstance. You might want to take a look af this window property in the language reference.

thanks alex. i have read that page but i still can’t figure out how to do that when it comes of do the code. could you give me a little code example maybe? again thanks a lot alex.

There is no “code”… just turn off the ImplictInstance for that window [see Inspector]

No need to turn off implicitinstance…

Create a desktop app with 2 windows, and on the first one place two pushbuttons.

In PB1.Action add:

  if Window2.Visible = true then
    window2.Close // -or- window2.visible = false
  end if

and in PB2.Action add:

window2.Show

A rule of thumb to remember is:

A window cannot be visible if it is not open. But an open window can be visible or invisible.

Just set Visible to False in the window editor.

I’ve done this for ages.

Sub WindowHide (WindowName As String) for i as integer = 0 to WindowCount - 1 Dim t as Introspection.TypeInfo = Introspection.GetType(window(i)) if t.Name = WindowName then window(i).Hide next i End Sub

An then you just have to write:

WindowHide (MyWindow) and MyWindow will hide only if it’s open.

thanks all of you for the responses. i found particularly useful the ramon sastre reply. it is just what i was looking for. i need something like the sub WindowHide proposed by ramon but will be WindowShow(WindowName as String) that shows the window ONLY if it was previously loaded. how could i do that?
i think maybe it could be

Sub WindowHide (WindowName As String) for i as integer = 0 to WindowCount - 1 Dim t as Introspection.TypeInfo = Introspection.GetType(window(i)) if t.Name = WindowName then window(i).SHOW '--> here is the only change next i End Sub

my question was solved 100% thanks everyone! :slight_smile: