summaryrefslogtreecommitdiff
path: root/examples/gui/helloworld/helloworld.pas
diff options
context:
space:
mode:
Diffstat (limited to 'examples/gui/helloworld/helloworld.pas')
-rw-r--r--examples/gui/helloworld/helloworld.pas56
1 files changed, 48 insertions, 8 deletions
diff --git a/examples/gui/helloworld/helloworld.pas b/examples/gui/helloworld/helloworld.pas
index b9921756..b09ec498 100644
--- a/examples/gui/helloworld/helloworld.pas
+++ b/examples/gui/helloworld/helloworld.pas
@@ -3,20 +3,60 @@ program HelloWorld;
{$mode objfpc}{$h+}
uses
- fpGUI, fpguipackage;
+ fpGUI
+ ,fpGFX { GFApplication }
+ ,gfxBase
+ ;
type
TMainForm = class(TForm)
- TextLabel: TLabel;
- lblClose: TLabel;
+ private
+ BoxLayout: TBoxLayout;
+ btnHello: TButton;
+ public
+ procedure AfterConstruction; override;
end;
+
+{ TMainForm }
+
+procedure TMainForm.AfterConstruction;
var
- MainForm: TMainForm;
+ lSize: TSize;
+begin
+ inherited AfterConstruction;
+ Name := 'MainForm';
+ BorderWidth := 8;
+ Text := 'fpGUI Application';
+
+ { every fpGUI app needs a layout manager }
+ BoxLayout := TBoxLayout.Create(self);
+ BoxLayout.Spacing := 8;
+ BoxLayout.VertAlign := vertFill;
+ InsertChild(BoxLayout);
+
+ { create our button }
+ btnHello := TButton.Create('Hello World!', self);
+ btnHello.CanExpandWidth := True;
+ btnHello.CanExpandHeight := True;
+ BoxLayout.InsertChild(btnHello);
+ { set a min and max size }
+ lSize.cx := 150;
+ lSize.cy := 100;
+ Wnd.SetMinMaxClientSize(lSize, lSize);
+end;
+
+
+var
+ MainForm: TMainForm;
begin
- Application.CreateForm(TMainForm, MainForm);
-
- Application.Run;
- MainForm.Free;
+ GFApplication.Initialize;
+ MainForm := TMainForm.Create(GFApplication);
+ try
+ MainForm.Show;
+ GFApplication.Run;
+ finally
+ MainForm.Free;
+ end;
end.