I know this has been raised previously but that answered question suggested different approach and it did really works for me.
Here's the link Enable a TButton of an MDI ChildForm upon closing of another MDI ChildForm.
However and again, I encountered this same simple challenge in another scenario.
I created a TButton in TForm1 to open TForm2 at the same time during opening it should disable the TButton to avoid recreation or reopening of TForm2.
By the way, I am using MDI here. Both forms I mentioned above are child forms.
Now, I wanted to enable back the TButton of TForm1 at the time of closing the TForm2 but I am getting an 'Access Violation Error'.
Here's the code I got for closing:
procedure TfrmChild2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
form1_u.frmChild1.btnOpen.Enabled := True; // 1. here's where the error code is coming
main_u.frmParent.menuitemOpen.Enabled := true; // 2. this one form main form has no problem
end;
I am surprised the second procedure above is okay, though its triggered from the MDI parent form, while the other child form isn't and it is throwing 'access violation error'.