Search code examples
delphifiremonkey

How clear all forms and open a new one in Firemonkey?


Let's suppose the user is navigating throughout an Android/iOS app and open the following forms:

Form A --> Form B --> Form C

In Form C he press a button to logout from the app. This should clear all the previous forms (including Form C) and open a new Form (Signin Form D).

So it would be something like that:

  1. Form A --> Form B --> Form C --> Press Logout Button
  2. Close Form A, B and C
  3. Open Form D
  4. Now if the user press the back button in Form D the app will be closed because there are no more forms in the task.

I tried to open Form D and close previous ones but it didn't freed completely the previous forms. Anyway to achieve this for Android/iOS?


Solution

  • I'm afraid this won't work exactly as you imagined. Why?

    In Delphi application the first form that is created becomes Application MainForm. Closing this form then closes the entire application.

    Now in your case you say that the Form A is the first form that is opened meaning that it automatically becomes the MainForm of your application. Thus closing it will close your application.

    So in order to achieve what you want you will have to make sure that your Form D is actually the first form that is created in your application.