1
I intend to create an unlimited number of instances of frmPai (MDI) that is created dynamically as follows:
class procedure TfrmPai.ShowForm;
var
frmPai: TfrmPai;
begin
frmPai := TfrmPai.Create(nil);
frmPai.Show;
end;
When closing run:
procedure TfrmPai.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
That one form
has a button that calls the frmFilho
to process and display a Progress bar.
To create the frmFilho
, a Procedure of callback to notify to the frmPai
that the processing has ended and display the result
Callback of frmPai
:
procedure TfrmPai.MyCallback(icont_process: Integer);
begin
Self.LabelResultado.Caption := IntToStr(icont_process)+' itens processados.');
end;
Creation of 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 in the execution of Callback...
How to check if the frmPai
to which the result should return has not been closed while the frmFilho
was processing, since frmPai
is created dynamically?
I believe the problem is in the creation of the Son, notice that you are creating him as
nil
. You shouldn’t pass the name "Dad"?– Junior Moreira
that was intentional... I needed them to be independent, so I could close formPai, but not in that case, I wouldn’t run callback (because I could give access Violation)
– luix10