Stop Window Auto Showing

Is there a reason a non implicit instance window auto shows when it goes out of scope?

Sub Action() Handles Action dim w as new window2() //fail some validation setting up window - so dont show it End Sub

The window always appears. Surely you have to call show , showmodal , hide etc to show it.

Is close the only way to ensure it is not shown?

Xojo 2019r1.1 macOS

set the window implicit instance property to false and it will not show, you will have to call w.show

it is set to false.

It doesn’t show when it goes out of scope, it shows when it comes into scope on the dim

Set the window visibility to false in the inspector if you don’t want it to show then set visible to true in code when you want to show it.

You will also want to set Visible to false.

(Julian beat me to it)

What’s the fame type set to?
It should NOT show by just creating a new instance as far as my knowledge

Window frame is a document, setting to other types does nothing.

Seems like a bug to me.

[code]dim w as new window2()

MsgBox “here”

[/code]

The window shows on MsgBox “here”

What if i want to show it within a certain window etc. I could not get to that code.

Also even if i never call show, with visible set to false it is still registered as an open Window in WindowCount.
I have to call close on the window to remove it.

[code]dim w as new window2()
w.Visible = false

if not w.Action_Init() then
w.close()
return
end if

w.ShowModalWithin(myParentWindow)[/code]

This appears to be the logic i have to implement to get it to work as I expected.

[quote=470981:@Graham Busch]Window frame is a document, setting to other types does nothing.

Seems like a bug to me.

[code]dim w as new window2()

MsgBox “here”

[/code]

The window shows on MsgBox “here”

What if i want to show it within a certain window etc. I could not get to that code.

Also even if i never call show, with visible set to false it is still registered as an open Window in WindowCount.
I have to call close on the window to remove it.[/quote]

The window should NOT be shown* but the Open Event should fire as that has to do with constructing the window. E.g. set the properties in the open event. If the default IDE setting is visible or the Open even has Self.Visible = True then it could possibly show.

  • unless you specify to do so in the Window.Open event

Sounds like a bug, i think you should make sure the Open event doesn’t have visibility code in it.

There is nothing in the window2 class, it’s from a simple test app. Only change made is turning off implicit instance.

Ah… IMPLICIT INSTANCE means that it is implied that a “NEW WINDOW” command is automatically executed, this normally causes the window in question to appear.

You did NOT have Implicit Instance, However, you did say “NEW WINDOW2”… which is an EXPLICIT INSTANCE, and therefore causes the window to appear

[quote=470997:@Dave S]Ah… IMPLICIT INSTANCE means that it is implied that a “NEW WINDOW” command is automatically executed, this normally causes the window in question to appear.

You did NOT have Implicit Instance, However, you did say “NEW WINDOW2”… which is an EXPLICIT INSTANCE, and therefore causes the window to appear[/quote]

It should not not if the Visible property in the IDE is set to false
basically that lets you create an instance, manipulate it without showing it

Graham, can you post up a small demo project where this is happening?

Create a new project
Add a new window (called window2)
Turn off implicit instance for window2
Add a button on window1 and add action event handler and add this code

[code]dim w as new window2()

MsgBox “here”

w.Show()[/code]

run it and notice window2 appears when msg box appears

Or only call dim w as new window2() in the action event.

So for all non implicit windows i need to turn off visible in the IDE and also ensure i close it if i return before showing it? (otherwise window stays in memory and is listed in WindowCount)

You need to go into the inspector for windows2 and unckeck Visible

And if you dont show it, it will stay around in memory, unless you close it, even though you never showed.

Windows are strange.

Windows don’t go “out of scope” because the framework holds a reference to them, so the reference count never goes to zero. They are different than “normal” objects in that you’re not the only one who cares about them.