Script in MDI forms
Hi...
I??m using the Method AddForm(Self) in the OnCreate event in the MDI forms.
In The Main Form:
Now, the script is executed in the MDI child Form1, who references the object
DataMod, added previously, works ok...
The form is destroyed in the OnClose event by using:
When i try to create the Form1 Again, the DataMod doesn??t exists anymore, in the fsGlobalUnit items. How To Proceed to AddForm and RemoveForm correctly, in these MDI forms ?
I??m using the Method AddForm(Self) in the OnCreate event in the MDI forms.
In The Main Form:
uses UDataMod;
procedure TMainForm.Create(Sender: TObject);
begin
 fsGlobalUnit.AddForm(DataMod); // UDataMod.pas, TDataModule... access to db
end;
Now, the script is executed in the MDI child Form1, who references the object
DataMod, added previously, works ok...
procedure TForm1.OnCreate(Sender: TObject);
begin
 fsGlobalUnit.AddForm(Self); // Works ok, now i can acess the form
 // and his components.
Â
 fsScript1.Run; // Execute the script in local MDI...
end;
The form is destroyed in the OnClose event by using:
procedure TForm1.OnClose(Sender: TObject; Action: TCloseAction);
begin
 //fsGlobalUnit.Remove(Form1);
 //fsGlobalUnit.RemoveItens(Form1);
 // i??ve tried to put the Remove methods BEFORE free the Form1, but doesn??t
 // works, in next time he gave me an error.
 Form1 := nil; //
 Action := caFree;
 fsGlobalUnit.Remove(Form1); // doesn??t happened anything...
 fsGlobalUnit.RemoveItens(Form1); // Remove the form and another controls, like
 // Datamodules added by main form.
end;
When i try to create the Form1 Again, the DataMod doesn??t exists anymore, in the fsGlobalUnit items. How To Proceed to AddForm and RemoveForm correctly, in these MDI forms ?
Comments