Atozed Forums
Form create/destroy best practise ? - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: Form create/destroy best practise ? (/thread-1432.html)



Form create/destroy best practise ? - SorenJensen - 12-12-2019

Hi All,

Usually I have a main form, allowing the user to select  a function, which then will create and show a form. If necessary, that form too, will create a new form, and when user is finished, it is released and the former form is shown again. And when user finishes, clicks a kind of "close" button, that form is finally released and the menu form is back on.

Now I want to call the form create without going back to the former with Release, meaning from the menu a new form (1st.) is created and shown. 1st. form creates and show a new form (2nd.), which again creates and show a form (3rd.). And when the user finished using 3rd. form, I want the program to go straight back to the menu program, bypassing form 2nd and 1st.

How do I do that, making sure all memory is released ?

Regards
Soren


RE: Form create/destroy best practise ? - Jose Nilton Pace - 12-12-2019

Hi Soren. Try this:
- from the menu a new form (1st.) is created and shown, DON'T RELEASE menu form.
- 1st. form creates and show a new form (2nd.), RELEASE 1st form.
- which again creates and show a form (3rd.), RELEASE 2nd form.
- And when the user finished using 3rd. form, RELEASE 3rd form.

Only Form Menu is created and not released, IW go back to him when you release 3rd form.


RE: Form create/destroy best practise ? - SorenJensen - 12-12-2019

Hi Jose,

Thank you for your notes. Just to be 100% clear:

In form 1 (and likewise in form 2) I would write:

procedure TForm1.CallNextForm;
begin
TForm2F.create(self).show;
Release;
end;

Regards
Soren


RE: Form create/destroy best practise ? - Jose Nilton Pace - 12-12-2019

Exactly.


RE: Form create/destroy best practise ? - kudzu - 12-12-2019

Form management is very similar to a normal desktop app. But one has to use Release instead of Free, and the actual release is delayed until control returns from user code to IntraWeb. This is because of how the web works, but its very similar otherwise.