Two Forms Program lazarus / 21-General ---------------------------------------------------------------------- cris75 · 2022-04-21 16:29 Hi, I'm developing a small GUI app to be used by some friends, small description of what I want to achieve: it will consist of two forms, at startup only the mainForm is shown, in this form there are both a button to "manually" load a file via OpenDialog and an image that tells the user to drop a file to load it using the drag&drop mechanism; if the file is valid (there will be a function that checks it and returns true on success) then the same file will be manipulated some way and "the output" will be shown in auxForm and at the same time mainForm must hide; at that point only auxForm will be visible until program termination (to be clear mainForm sould never be shown again after first step of "loading" file); if the user now close auxForm then the program must exit and in the meantime mainForm should never be visible; the program will be set as default program for a certain file extension, so when the user will double click on a file with that extension the app will start; in that case ParamStr(1) should contain my file name, and BEFORE showing any Form i want to invoke file validation and manipulation and at that point show directly auxForm with the elaborated output (in short, i don't want to show mainForm if the program is started via double click on a file); I'm starting with the code that will be used for file checks and manipulation, but I'm not really sure how to obtain this "Forms behaviour", in particular the program termination via auxForm closure and if it's better to create auxForm (or both) via IDE or manually, so any suggestion or link to examples or documentation will be very appreciated; Thank you, Cris ---------------------------------------------------------------------- wp · 2022-04-21 17:15 Try to understand the attached project. Code in the main form to show the aux form: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TMainForm.btnAuxFormClick(Sender: TObject);begin  Hide;  AuxForm.ShowModal;  Close;end; This means: /1/ The main form is hidden. /2/ The aux form is shown modally, i.e. it gets full control of the application. This is not absolutely necessary, but the easiest way to "forget about the main form". The rest of the application runs inside the AuxForm.ShowModal. /3/ After the aux form is closed control returns to the main form. But the Close command closes that, too, and this closes the application. ---------------------------------------------------------------------- cris75 · 2022-04-22 10:25 thank you @wp i confess I'm feeling a little dumb.. sorry if i wasted your time on something so obvious  your example (with additions -see attachment-) reflects exactly the behaviour i had in mind, thank you very much for your help  P.s. I take this opportunity to thank all the beautiful people who offer their help (for free!!) in this wonderful forum, i always think it's so nice, it's something no one should take for granted, me in the first place