Close all Opened Windows at Open the next Window

Hi all

Is there a way to close all opened windows when I will open a new window?

I’m using close event, But I only know how to close and show a certain window. :frowning:

Thanks

You get the count of the windows (see http://documentation.xojo.com/index.php/WindowCount) and loop over them to close them.

The next part is a bit more interesting. You could do an if then else

if myWindowName = "do this window" then dothisWindow.open elseif myWindowName = "blabla window " then blablaWindow.open end if

If you have lots and lots of windows introspection is the way to go.

[code]Function getWindowName(Extends theWindow as Window) As String

'returns the name of a Window

Dim theTypeInfo as Introspection.TypeInfo = Introspection.GetType(theWindow)
Return theTypeInfo.Name

End Function[/code]

gives you the name. So loop over the windows, get their name and if the name is what you want use the index to open.

for currentWindow as integer = 1 to WindowCount if window(currentWindow).getWindowName = "myWindowName" then window(currentWindow).open next

Code is not tested.

Closing all windows:

Do Until WindowCount = 0 Window(0).Close() // Window(0) is the frontmost window Loop

[quote=208438:@Eli Ott]Closing all windows:

Do Until WindowCount = 0 Window(0).Close() // Window(0) is the frontmost window Loop[/quote]
Thanks so much!!!