Simple Question

Scubaticus

Active Member
Licensed User
Sorry for this very basic question, but I just wanna know.

I have two screens. Every screen has the same menu and from that menu I can jump to screen 1 and 2.

Every screen has it's own sub and shows itself by issuing a screen.show
What happens with screen1 when I choose from screen 1 to go to screen 2

So i.e.

Screen1.Show - menu select screen 2
Screen2.Show - menu select screen 1
Screen1.Show - menu select screen 2
Screen2.Show

Is there a stack buildup? Should I issue a close of screen1 somehow before screen2.show or is the the way to do it?

Scub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm not sure if I understood your question.
Forms are stacked.
If you call Screen2.Show and then close Screen2 you will see Screen1.
If you call Screen2.Show and then Screen1.Show, Screen1 will show above Screen2 (and only above).
Remember that the first form that is shown will be the "main form" and the application will end when it will be closed.
 

Scubaticus

Active Member
Licensed User
I'm not sure if I understood your question.

Yes you did and give me the answer I needed. I use a show routine to show the wanted screen which has a .show, but not a close of the screen it's coming from, so stacking screens.

So when I do a .close of a screen, the app only ends when the last screen is closed?

Scub.
 

Scubaticus

Active Member
Licensed User
To get it all clear to me I have one question left:

Does the next code has the same result (from memory usage view)


From1.Show, Form2.Show, Form3.Show, Form2.Show, Form1.Show

and

Form1.Show
Form2.Show,Form2.Close
Form3.Show,Form3.Close
Form2.Show,Form2.Close
Form1.Show

And do I have two Form2 stacked in the first sample or will it just do a re-display of the already stacked Form2 when I do the Form2.Show the 2nd time?

Scub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
So when I do a .close of a screen, the app only ends when the last screen is closed?
No.
The app ends when you close the "main form" - the first form that was shown.


And do I have two Form2 stacked in the first sample or will it just do a re-display of the already stacked Form2 when I do the Form2.Show the 2nd time?
No. Form2 will be redisplayed, and will change its position in the stack.

When you close a form (not the main form) the form is not destroyed so there is no memory loss caused by showing and closing forms.
 
Top