I have 2 MDI ChildForms and the Child1 has a TButton to open the Child2. I do not have any issue opening it at the same time disable the TButton to prevent Child2 from recreating again using TButton.
Now, the challenge comes when I want the TButton of Child1 back to "enabled" when I closed the Child2.
I am getting access error when doing these code:
procedure TfrmChild2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
child1_u.frmChild1.btnOpenChild2Form.Enabled := True;
Action := caFree;
end;
I understand there is somehow a different approach when dealing with MDI. I figured it out when I did the code for disabling the TButton during opening at runtime below:
procedure TfrmMain.btnOpenChild2(Sender: TObject);
begin
TfrmChild2.Create(frmMain);
btnOpenChild2.Enabled := False;
end;
But to enable it back when the Child2 form is closed is a challenge.
I tried to create a procedure in the MainForm (Owner) to trigger the enable of TButton in the Child1:
procedure TfrmMain.EnableButtonAtChild1();
begin
child1_u.frmChild1.btnOpenChild1Form.Enabled := True;
end;
and called at runtime during OnClose of Child2:
procedure TfrmChild2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
EnableButtonAtChild1();
end;
I am new to MDI and I need to understand how accessing components works particular this simple case. I will appreciate any help here.