PageRenderTime 29ms CodeModel.GetById 15ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/examples/helloform.pp

http://github.com/graemeg/lazarus
Pascal | 71 lines | 37 code | 12 blank | 22 comment | 0 complexity | 0aa0bb4b73d4a4f500526ba84069b6f7 MD5 | raw file
 1{
 2 ***************************************************************************
 3 *                                                                         *
 4 *   This source is free software; you can redistribute it and/or modify   *
 5 *   it under the terms of the GNU General Public License as published by  *
 6 *   the Free Software Foundation; either version 2 of the License, or     *
 7 *   (at your option) any later version.                                   *
 8 *                                                                         *
 9 *   This code is distributed in the hope that it will be useful, but      *
10 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
11 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
12 *   General Public License for more details.                              *
13 *                                                                         *
14 *   A copy of the GNU General Public License is available on the World    *
15 *   Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also      *
16 *   obtain it by writing to the Free Software Foundation,                 *
17 *   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.        *
18 *                                                                         *
19 ***************************************************************************
20}
21unit HelloForm;
22
23{$mode objfpc}
24{$H+}
25
26interface
27
28uses SysUtils, Classes, Forms, Buttons, StdCtrls;
29
30type
31   THello = class(TForm)
32     button1 : TButton;
33   public
34     constructor Create(AOwner: TComponent); override;
35     procedure button1Click(Sender : TObject);
36   end;
37
38var
39   Hello : THello;
40
41implementation
42
43constructor THello.Create(AOwner: TComponent);
44begin
45   inherited CreateNew(AOwner, 1);
46   Caption := 'Hello World';
47   Width := 200;
48   Height := 75;
49   Left := 200;
50   Top := 200;
51
52   button1 := TButton.Create(Self);
53   button1.OnClick := @button1click;
54   button1.Parent := Self;
55   button1.left := (width - 75) div 2 ;
56   button1.top := (height - 32) div 2;
57   button1.width := 75;
58   button1.height := 32;
59   button1.caption := 'Close';
60   button1.Show;
61   
62   Self.Constraints.MaxWidth:= 500; 
63end;
64
65procedure THello.button1Click(Sender : TObject);
66begin
67  close;
68end;
69
70end.
71