[Lazarus] Sample code needed to create form at runtime only (see mock up below).
Mattias Gaertner
nc-gaertnma at netcologne.de
Fri Sep 10 18:27:29 CEST 2010
On Sun, 05 Sep 2010 19:18:49 +1000
Peter E Williams <foss.game.pascal.developer at iinet.net.au> wrote:
> Hi Felipe and All,
>
> On Sun, 2010-09-05 at 07:01 +0200, Felipe Monteiro de Carvalho wrote:
> > On Sun, Sep 5, 2010 at 6:39 AM, Peter E Williams
> > <foss.game.pascal.developer at iinet.net.au> wrote:
> > > Questions:
> > > 1) Does the Memo1, OK_Button and Cancel TButton need to be in a
> > > TGroupBox???
> > > 2) Also, should the TImage be in a TGroupBox???
> >
> > I think that to use the splitter you need to group the elements using
> > a panel. I vaguely remember that if you have something like:
> >
> > Panel 1 - Splitter - Panel 2
>
> My question is:
> How do I create a TForm and TSplitter and 2 x TPanel's at runtime?!?
I created an example here:
http://wiki.lazarus.freepascal.org/Working_with_TSplitter
> 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;
> Splitter1 : TSplitter;
> Panel1, Panel2 : TPanel;
> success_modal_result : boolean;
> OK_button, Cancel_button : TButton;
> Image1 : TImage;
> begin
> FormA := TForm.Create; // Are there any parameters here????
>
> try
> FormA.caption := 'Image and Comments for ' + Image_filename;
>
> Splitter1 := TSplitter.Create( FormA );
> Splitter1.Parent := FormA;
> //Splitter1.Visible := True;
Visible=true is default.
> Splitter1.Align := alRight;
> // do I need to set any other properties like Height, Width, Top,
> Left ???
You can set the Width.
> Panel1 := TPanel.Create( FormA );
> Panel1.Parent := FormA;
> Panel1.Visible := True;
> Panel1.Align := alClient;
>
> Memo1 := TMemo.Create( FormA );
> Memo1.Parent := Panel1;
> Memo1.Visible := True;
>
> Memo1.Align := ?????????
Memo1.Align := alClient; // fill Panel1
> // do I need to set any other properties like Height, Width, Top,
> Left ???
No.
> // will this work ????
>
> Memo1.Strings := StringList1.Strings;
Memo1.Lines := StringList1; // this calls Assign
> OK_Button := TButton.Create( FormA );
> OK_Button.Parent := FormA;
> OK_Button.Visible := True;
> OK_Button.ModalResult := mrOK;
>
> OK_Button.Align := ????????????
Don't know. Maybe you should put all the buttons into a TPanel or use
TButtonPanel or use anchors.
See here:
http://wiki.lazarus.freepascal.org/Autosize_/_Layout#Example:_a_button_panel
> // do I need to set any other properties like Height, Width, Top,
> Left ???
Normally you do
OK_Button.AutoSize:=true;
>[...]
Mattias
More information about the Lazarus
mailing list