Examples: Restructure GroupBox demo.

This commit is contained in:
wp_xyz 2021-12-27 11:51:44 +01:00
parent 99878e8ac6
commit 29267f11a8
6 changed files with 234 additions and 0 deletions

View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="12"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<Title Value="groupbox_demo"/>
<Scaled Value="True"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<XPManifest>
<DpiAware Value="True"/>
</XPManifest>
<Icon Value="0"/>
</General>
<BuildModes>
<Item Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
<UseFileFilters Value="True"/>
</PublishOptions>
<RunParams>
<FormatVersion Value="2"/>
</RunParams>
<RequiredPackages>
<Item>
<PackageName Value="LCL"/>
</Item>
</RequiredPackages>
<Units>
<Unit>
<Filename Value="groupbox_demo.lpr"/>
<IsPartOfProject Value="True"/>
</Unit>
<Unit>
<Filename Value="groupbox_form.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<ResourceBaseClass Value="Form"/>
</Unit>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="groupbox_demo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions>
<Item>
<Name Value="EAbort"/>
</Item>
<Item>
<Name Value="ECodetoolError"/>
</Item>
<Item>
<Name Value="EFOpenError"/>
</Item>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,25 @@
program groupbox_demo;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
{$IFDEF HASAMIGA}
athreads,
{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, groupbox_form
{ 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,64 @@
object Form1: TForm1
Left = 270
Height = 350
Top = 131
Width = 350
Caption = 'Groubox Demo v0.1'
ClientHeight = 350
ClientWidth = 350
LCLVersion = '2.3.0.0'
object grpTst: TGroupBox
Left = 10
Height = 200
Top = 70
Width = 300
Caption = 'Groupbox with 2 Buttons'
ClientHeight = 180
ClientWidth = 296
TabOrder = 0
object Button2: TButton
Left = 200
Height = 30
Top = 50
Width = 80
Caption = 'Width ++'
OnClick = Button2Click
TabOrder = 0
end
object CheckBox1: TCheckBox
Left = 200
Height = 19
Top = 100
Width = 77
Caption = 'CheckBox1'
TabOrder = 1
end
object Button1: TButton
Left = 50
Height = 30
Top = 50
Width = 80
Caption = 'Height ++'
OnClick = Button1Click
TabOrder = 2
end
end
object Button3: TButton
Left = 50
Height = 30
Top = 30
Width = 80
Caption = 'Show'
OnClick = Button3Click
TabOrder = 1
end
object Button4: TButton
Left = 200
Height = 30
Top = 30
Width = 80
Caption = 'Hide'
OnClick = Button4Click
TabOrder = 2
end
end

View File

@ -0,0 +1,69 @@
unit groupbox_form;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
CheckBox1: TCheckBox;
grpTst: TGroupBox;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
if Assigned(grpTst) then
grpTst.Height := grpTst.Height + 10;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if Assigned(grpTst) then begin
grpTst.Width := grpTst.Width + 10;
grpTst.Show;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if Assigned(grpTst) then begin
grpTst.Show;
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
if Assigned(grpTst) then begin
grpTst.Hide;
end;
end;
end.