1
0
lazarus-tutorials/anchoring/main_anchoring.pas
2021-10-14 15:36:07 -04:00

80 lines
1.2 KiB
ObjectPascal

unit main_anchoring;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
var
Memo1, Memo2: TMemo;
splitter: TSplitter;
sl: TStringList;
begin
Height := 140;
sl := TStringList.Create;
try
sl.CommaText := 'Memo1 line2 line3 line4 line5';
Memo1 := TMemo.Create(Self);
with Memo1 do
begin
Lines.AddStrings(sl);
Align := alLeft;
Parent := Self;
end;
splitter := TSplitter.Create(Self);
with splitter do
begin
Align := alNone;
Left := 120;
Parent := Self;
AnchorParallel(akBottom, 0, Parent);
end;
Memo1.AnchorToNeighbour(akRight, 0, splitter);
sl.Clear;
sl.CommaText := '"Memo 2", "2nd added line","3rd added line", "4th added line", "5th added line"';
Memo2 := TMemo.Create(Self);
with Memo2 do
begin
Align := alRight;
AnchorToNeighbour(akLeft, 0, splitter);
Lines.AddStrings(sl);
Parent := Self;
end;
finally
sl.Free;
end;
end;
end.