procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
end;
should be enough.
I have found that neither of these will work on a form that is minimized and borderless. Once minimized, you need to restore the program with the Windows icon. Then using a main menu exit either close or terminate the program. The program minimizes, it does not close. I have just started looking for a solution. This was my first stop.
I have found that neither of these will work on a form that is minimized and borderless.
If it is a main form then simply put there a button and its OnClick method:No. Closes the form.Code: [Select]procedure TForm1.Button1Click(Sender: TObject);
should be enough.
begin
Close;
end;
If it's the main form, Close() terminates the application (my experience).
If it is a main form then simply put there a button and its OnClick method:Code: [Select]procedure TForm1.Button1Click(Sender: TObject);
should be enough.
begin
Close;
end;
When the application is closed externally (e.g. by the methods you cite), the OnClose event will be fired, just as if you had called Close, so there is no need (or shouldn't be) to call the button's OnClick handler.
In fact it does terminate if I wait long enough (long enough being about 10 seconds). Not really the user experience one would want though and I'd missed it because I had not been waiting that long.
You shouldn't have Button1.Click in FormClose if you have Form1.Close in Button1Click. FormClose is called after Form1.Close.
procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction); begin NSLog(NSStr('leaving...')); Application.BringToFront; // needed // Button1.Click; end;