summaryrefslogtreecommitdiff
path: root/examples/gui/helloworld/helloworld.pas
blob: bbcfd99b355136431a8703aaa827bc1c73057ba4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
program HelloWorld;

{$mode objfpc}{$h+}

uses
  fpGUI
  ,fpGFX    { GFApplication }
  ,gfxBase
  ;

type
  TMainForm = class(TFForm)
  private
    BoxLayout: TFBoxLayout;
    btnHello: TFButton;
  public
    procedure AfterConstruction; override;
  end;


{ TMainForm }

procedure TMainForm.AfterConstruction;
var
  lSize: TSize;
begin
  inherited AfterConstruction;
  Name        := 'MainForm';
  BorderWidth := 8;
  Text        := 'fpGUI Application';

  { every fpGUI app needs a layout manager }
  BoxLayout := TFBoxLayout.Create(self);
  BoxLayout.Spacing       := 8;
  BoxLayout.VertAlign     := vertFill;
  InsertChild(BoxLayout);

  { create our button }
  btnHello := TFButton.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
  GFApplication.Initialize;
  MainForm := TMainForm.Create(GFApplication);
  try
    MainForm.Show;
    GFApplication.Run;
  finally
    MainForm.Free;
  end;
end.