/examples/helloform.pp

http://github.com/graemeg/lazarus · Puppet · 71 lines · 59 code · 12 blank · 0 comment · 1 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. }
  21. unit HelloForm;
  22. {$mode objfpc}
  23. {$H+}
  24. interface
  25. uses SysUtils, Classes, Forms, Buttons, StdCtrls;
  26. type
  27. THello = class(TForm)
  28. button1 : TButton;
  29. public
  30. constructor Create(AOwner: TComponent); override;
  31. procedure button1Click(Sender : TObject);
  32. end;
  33. var
  34. Hello : THello;
  35. implementation
  36. constructor THello.Create(AOwner: TComponent);
  37. begin
  38. inherited CreateNew(AOwner, 1);
  39. Caption := 'Hello World';
  40. Width := 200;
  41. Height := 75;
  42. Left := 200;
  43. Top := 200;
  44. button1 := TButton.Create(Self);
  45. button1.OnClick := @button1click;
  46. button1.Parent := Self;
  47. button1.left := (width - 75) div 2 ;
  48. button1.top := (height - 32) div 2;
  49. button1.width := 75;
  50. button1.height := 32;
  51. button1.caption := 'Close';
  52. button1.Show;
  53. Self.Constraints.MaxWidth:= 500;
  54. end;
  55. procedure THello.button1Click(Sender : TObject);
  56. begin
  57. close;
  58. end;
  59. end.