GrahamDLovell
asked on
In Delphi VCL, how can you exit without completing all actions?
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:
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.
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);
begin
MessageDlg('I am here', mtInformation, [mbOK], 0);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
ActiveControl := Button1;
end;
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It's not a 'golden' method I guess, still thinking of something better.
What kind of functionality do you have in the OnExit() of buttons?
What kind of functionality do you have in the OnExit() of buttons?
ASKER
Depending on the value entered into the field, other fields are made visible or invisible, descriptions are changed, etc.
Your method will be workable, and not too hard to implement.
Your method will be workable, and not too hard to implement.
ASKER
I suppose I should have thought of it. I will have to put it on every field exit routine, but it will improve the functionality quite a bit.
Thanks.