Unload/Reload Same Window

Hey all,
I’m wanting to smoothly unload and reload the same window (a bunch of stuff may have changed on this screen) so that any changes are displayed. What is the best way to do this? In this case, I tried:

mainscreen.close mainscreen.show

Doesn’t work…just unloads the window and stops.

I tried using mainscreen.close in the window and then putting mainscreen.show in the Close event of the window, doesn’t work either.

Thanks!

if you are updating the window… don’t close it… invalidate it

mainscreen.invalidate
or
mainscreen.updatenow

I know about Invalidate…the project itself assigns new values to the stuff on the mainscreen window, and I want it to just unload and reload again to display the stuff that is loaded with the window opening at the start.

I should note the above code works with VB6 fine…thus the confusion. :slight_smile:

Ad the docs say:

[quote]Window.Close method
Closes the window. Once closed, a window cannot be refreshed or redrawn.[/quote]
So you need to create a new instance or just don’t close the window.

this is XOJO… not VB… things are different…

the best way actually is to invalidate each control as you change them

Would turning off ‘Implicit Instance’ work for what I want? Instantiating a new window in the CancelClose event?

please explain why invalidate isn’t working for you?

[quote=114258:@Derek DiBenedetto]Hey all,
I’m wanting to smoothly unload and reload the same window (a bunch of stuff may have changed on this screen) so that any changes are displayed. What is the best way to do this? In this case, I tried:

mainscreen.close mainscreen.show

Doesn’t work…just unloads the window and stops.

I tried using mainscreen.close in the window and then putting mainscreen.show in the Close event of the window, doesn’t work either.
![/quote]

dim newindow as mainscreen mainscreen.close

Will create a clone of mainwindow and close the original. Now you have to make sure to set newindow.left and newwindow.top to the same as mainwindow so it appears to simply update.

Now this is not a very elegant way to update a window…

Thanks, Michel! I stumbled onto your solution by accident once I saw that windows are classes themselves. But I decided not to unload the window and just update the relevant controls and use window.Invalidate.