1
0

Add anchoring example

This commit is contained in:
Timothy Warren 2021-10-14 15:36:07 -04:00
parent 09eac57f84
commit 32efe43002
6 changed files with 189 additions and 0 deletions

BIN
anchoring/anchoring Executable file

Binary file not shown.

BIN
anchoring/anchoring.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

79
anchoring/anchoring.lpi Normal file
View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="11"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="anchoring"/>
<Scaled Value="True"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<XPManifest>
<DpiAware Value="True"/>
</XPManifest>
<Icon Value="0"/>
</General>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
<UseFileFilters Value="True"/>
</PublishOptions>
<RunParams>
<FormatVersion Value="2"/>
<Modes Count="0"/>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="anchoring.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="main_anchoring.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<ResourceBaseClass Value="Form"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<Target>
<Filename Value="anchoring"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

22
anchoring/anchoring.lpr Normal file
View File

@ -0,0 +1,22 @@
program anchoring;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, main_anchoring
{ you can add units after this };
{$R *.res}
begin
RequireDerivedFormResource:=True;
Application.Scaled:=True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,9 @@
object Form1: TForm1
Left = 361
Height = 240
Top = 125
Width = 320
Caption = 'Form1'
OnCreate = FormCreate
LCLVersion = '2.0.12.0'
end

View File

@ -0,0 +1,79 @@
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.