[Lazarus] Sample code needed to create form at runtime only (see mock up below).

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Sun Sep 5 21:41:32 CEST 2010


>  FormA := TForm.Create; // Are there any parameters here????

use:

FormA := TForm.Create(Application); if you want the form to be freed
when the program ends automatically

FormA := TForm.Create(nil); if you want to control where the form will be freed

>    Splitter1.Align := alRight;
>    // do I need to set any other properties like Height, Width, Top,
> Left ???

No, you can use either position variables or align, not both at the
same time. Sometimes Top and Left before align can be useful I think,
but I am not sure.

>    Memo1 := TMemo.Create( FormA );
>    Memo1.Parent := Panel1;
>    Memo1.Visible := True;
>    Memo1.Align := ?????????
>    // do I need to set any other properties like Height, Width, Top,
> Left ???

This doesn't matter. You can place this anywhere you want. Usually by
specifying Height, Width, Top and Left and Align isn't used then.

The same for all other very similar questions in different controls
inside the panels.

>    // will this work ????
>
>    Memo1.Strings := StringList1.Strings;

No, it should probably be:

Memo1.Lines.Assign(StringList1);

>    if FileExists ( Image_filename ) then <<<--- Unicode issue, use FileUtil.FileExists instead
>    begin
>      Image1.Filename := Image_filename; <<-- Wrong one
>      Image1.LoadFromFile( Image_filename ); <<<--- Correct one

See also:

http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tcustomimage.html

I don't think that TImage has a property FileName. You can use the
Lazarus code editor to check which properties and methods are
available in a class. Type "Image1." and wait a few seconds for the
list of methods to appear. As you type more letters it will refine the
list to show the ones that match your partial string.

-- 
Felipe Monteiro de Carvalho




More information about the Lazarus mailing list