I want to create an unlimited number of instances of frmPai (MDI) that is dynamically created as follows:
class procedure TfrmPai.ShowForm;
var
frmPai: TfrmPai;
begin
frmPai := TfrmPai.Create(nil);
frmPai.Show;
end;
When I close I run:
procedure TfrmPai.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
This form
has a button that calls frmFilho
to render and display a progress bar .
To create frmFilho
, a procedure callback is requested to notify frmPai
that the processing is finished and display the result
Callback of frmPai
:
procedure TfrmPai.MyCallback(icont_process: Integer);
begin
Self.LabelResultado.Caption := IntToStr(icont_process)+' itens processados.');
end;
Creating frmFilho
:
class procedure TfrmFilho.ShowForm(AMyCallback: TMyCallback);
var
frmFilho: TfrmFilho;
begin
frmFilho := TfrmFilho.Create(nil);
with frmFilho do
begin
FMyCallback := AMyCallback;
Show;
end;
end;
The problem occurs when executing Callback ...
How to check if the instance of frmPai
to which the result should return was not closed while frmFilho
was processing, since frmPai
is created dynamically?