I have exit procedures on lots of visual controls, but when the user hits buttons with the function cancel or exit I want to stop processing on all these exit processes.
Since the program does not get to the Cancel or Exit buttons until it has it completed the exit processes, it takes two clicks to exit the form.
Is the unavoidable, or is there a way this natural processing can be circumvented?
Here is a piece of code I have written to demonstrate the problem:
procedure TForm1.Button1Exit(Sender: TObject);
MessageDlg('I am here', mtInformation, [mbOK], 0);
procedure TForm1.Button2Click(Sender: TObject);
procedure TForm1.FormActivate(Sender: TObject);
ActiveControl := Button1;
In this program, it starts with the focus on Button1, so when I click Button2, I still get the message from Button1. This is the type of action I want to avoid.