Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

application terminate help

Tags:

forms

delphi

in my project i have two forms ,when i clicked show form 2 button in form1 ,form2 will pop up ,i want to terminate my whole application by clicking close button on form2 ,

can anyone please tell me how can i do this ?

like image 504
noob Avatar asked Dec 03 '22 13:12

noob


2 Answers

Do not use Application.Terminate if you want your OnCloseQuery and OnClose handlers of the main app form to be called (for example to be able to cancel this or to ask whether to save modified files or such).

You can call

Application.MainForm.Close;

instead, from all forms (even the main form itself).

like image 149
mghie Avatar answered Dec 29 '22 14:12

mghie


If you mean when a TButton called Close is clicked, then in the Button.OnClick event call Application.Terminate;

If you mean when the form's X button is clicked, then in Form2's OnClose event, call Application.Terminate;

like image 37
J__ Avatar answered Dec 29 '22 13:12

J__