1
0

Add basic GUI example

This commit is contained in:
Timothy Warren 2021-10-08 14:32:29 -04:00
parent 00f3dfe30c
commit 1f46c445ad
5 changed files with 165 additions and 0 deletions

BIN
first_gui/first_gui.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

79
first_gui/first_gui.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="first_gui"/>
<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="first_gui.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="umain.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<ResourceBaseClass Value="Form"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<Target>
<Filename Value="first_gui"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2Set"/>
</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
first_gui/first_gui.lpr Normal file
View File

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

22
first_gui/umain.lfm Normal file
View File

@ -0,0 +1,22 @@
object Form1: TForm1
Left = 811
Height = 240
Top = 410
Width = 320
BorderIcons = [biSystemMenu]
Caption = 'Form1'
ClientHeight = 240
ClientWidth = 320
LCLVersion = '2.0.12.0'
object DateBtn: TButton
Left = 70
Height = 52
Top = 94
Width = 181
Caption = 'Show Date'
Font.Style = [fsBold]
OnClick = DateBtnClick
ParentFont = False
TabOrder = 0
end
end

42
first_gui/umain.pas Normal file
View File

@ -0,0 +1,42 @@
unit umain;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
DateBtn: TButton;
procedure DateBtnClick(Sender: TObject);
private
function TodayAsString: string;
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.DateBtnClick(Sender: TObject);
begin
ShowMessageFmt('Today is %s', [TodayAsString]);
end;
function TForm1.TodayAsString: string;
begin
Result := FormatDateTime('dddd, mmm d, yyyy', Now);
end;
end.