I am using the code below to close an MDI child form by clicking on the system close button, and it works fine:
procedure Tfrm_main.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action := caFree;
end;
But how if I want to close the MDI child form by using a standard button (inside the child form itself). If I call Close
within an event handler, then I get an access violation exception.
Is there any way to close the MDI child form by using a standard button (not the system close button) placed inside the child form itself, without raising an access violation exception?
I've done searching similar questions, and tried various code, but still got the exception.