[Lazarus] SVN2 out of sync

Torsten Bonde Christiansen tc at epidata.dk
Mon Sep 6 08:27:05 CEST 2010


> I would guess something like:
> { this code is all untested and typed straight into my email client }
> 
> procedure create_formA( 
>   Image_filename : string; StringList1 : TStringList );
> var
>   FormA : TForm;
> (...)

wouldn't it be better to define the form within the IDE, with all of its 
components; then exclude it from the autocreate forms list (remove also 
the Var Form1: TForm1 from the unit if you like...) and finally 
create/free an instance of it whenever needed, like:

you'll have already:
Type TFormA: Class(TForm)
blablabla


then you do

procedure create_formA(Image_filename :string; StringList1: TStringList);
var
   FormA : TFormA;
   success_modal_result : boolean;
begin
   try
     FormA := TFormA.Create; // Are there any parameters here????
     FormA.Memo1.Strings := StringList1.Strings;
     if FileExists ( Image_filename ) then
     begin
       FormA.Image1.Filename := Image_filename;
       FormA.Image1.LoadFromFile( Image_filename );
       success_modal_result := (formA.showmodal = mrOK);
     end
     else
       showmessage(format('Error: Image filename %s Cannot be loaded 
because it does not exist.', [Image_filename]);
   finally
     FreeAndNil(FormA);
   end;
end;


Just my 2c, I would do so...

Cheers, A.





More information about the Lazarus mailing list