Script works only in the first time.

Hi.

Adding a MDI form with fsGlobalUnit.AddForm(Form_Sample) works only in the first time. When i close the form and free-it by:

procedure TForm_Sample.OnClose(Sender: TObject; var Action: TCloseAction);
begin
Form_Sample := nil; // so i can test if itself is nil and recreate-it.
Action := caFree; // free the mdi form, the window must be closed.
end;

When i try to create the same form Form_Sample, the script doesn??t works anymore. I??m using the following code in the script:

begin
Form_Sample.Label2.Caption := 'Test';
end.

In the OnCreate event of the form, i??m adding itself by AddForm(Self).

Is that correct ? Please, i need help. Many days ago i??m trying to do that.

Thanks a lot.

Comments

  • edited 9:15AM
    You can add form by fsGlobalUnit.AddForm only one time.
  • edited May 2004
    Calling AddForm just one time works only in the first. When i create the form again (WITHOUT use AddForm), the script gives me a Access Violation Exception. How to proceed ? I need to recreate the forms many times, with the same name.
  • edited 9:15AM
    You can't destroy the form added by AddForm, then rectreate it and try to access.
    I'll try to fix it in the next release.
  • edited 9:15AM
    To resolve the problem while you don??t fix the 'bug', i??m using that:
    procedure TMDIForm1.OnCreate(Sender: TObject);
    begin
      with fsGlobalUnit do
      begin
        AddedBy := Self;
        AddForm(Self);
        AddedBy := nil;
      end;
    end;
    
    procedure TMDIForm1.OnClose(Sender: TObject; Action: TCloseAction);
    begin
      fsGlobalUnit.Remove(Self);
      fsGlobalUnit.RemoveItens(Self); // will remove only objects created by itself.
    end;
    

    Well, it??s working fine, is there any problem to do that ? limitations or memory
    problems ?

    Thanks a lot.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.