File: notebooktest.pp

package info (click to toggle)
lazarus 0.9.28.2-12
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 93,096 kB
  • ctags: 89,312
  • sloc: pascal: 820,189; xml: 202,194; makefile: 110,323; sh: 2,460; perl: 395; sql: 174; ansic: 133
file content (136 lines) | stat: -rw-r--r-- 3,915 bytes parent folder | download | duplicates (2)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
{  $Id: notebooktest.pp 7869 2005-10-01 00:38:04Z mattias $  }
{
 /***************************************************************************
                               NoteBookTest.pp  
                             -------------------




 ***************************************************************************/

 ***************************************************************************
 *                                                                         *
 *   This source is free software; you can redistribute it and/or modify   *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This code is distributed in the hope that it will be useful, but      *
 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
 *   General Public License for more details.                              *
 *                                                                         *
 *   A copy of the GNU General Public License is available on the World    *
 *   Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also      *
 *   obtain it by writing to the Free Software Foundation,                 *
 *   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.        *
 *                                                                         *
 ***************************************************************************
}
{
@abstract(An example application for TNotebook)
@author(NoteBookTest.pp - Marc Weustink <weus@quicknet.nl>)
}
program NotebookTest;
 
{$mode objfpc}{$H+}

uses
  Interfaces, Classes, Controls, Forms, Buttons, SysUtils, StdCtrls,
  Graphics, ExtCtrls, LclProc;

type

  TForm1 = class(TFORM)
    notebook1 : TNotebook;
    Button1: TButton; 
    Button2: TButton; 
    procedure Button1CLick(Sender : TObject);
    procedure Button2CLick(Sender : TObject);
  public
    constructor Create(AOwner: TComponent); override;	
  end;

  
constructor TForm1.Create(AOwner: TComponent);	
begin
  inherited Create(AOwner);
  Caption := 'Notebook Testing';
  Left := 0;
  Top := 0;
  Width := 700; 
  Height := 300;
  Position:= poMainFormCenter;

  Button1 := TButton.Create(Self);
  with Button1 do begin
    Top:= 0;
    Left:= 0;
    Width:= 50;
    Height:= 20;
    Parent:= Self;
    Caption := 'Button';
    OnClick := @Button1Click;
  end;
  
  Button2 := TButton.Create(Self);
  with Button2 do begin
    Top:= 0;
    Left:= 50;
    Width:= 50;
    Height:= 20;
    Parent:= Self;
    Caption := 'Button';
    OnClick := @Button2Click;
  end;

  NoteBook1 := TNoteBook.Create(Self);
  with NoteBook1 do
  begin
    Top:= 25;
    Left:= 0;
    Width:= 650;
    Height:= 250;
    Parent:= Self;
  end;
end;

procedure TForm1.Button1Click(Sender : TObject);
var
  NewPageIndex: integer;
  NewPage: TPage;
  PageLabel: TLabel;
begin
  NewPageIndex := Notebook1.Pages.Add(Format('[Page %d]', [Notebook1.Pages.Count]));
  NewPage := Notebook1.Page[NewPageIndex];
  PageLabel := TLabel.Create(Self);
  with PageLabel do
  begin
    Left := 20;
    Top := 10 + NewPageIndex * 20;
    Width := 500;
    Height := 20;
    Caption := Format('This is page [%d]',[NewPageIndex]);
    Parent := NewPage;
  end;
end;

procedure TForm1.Button2Click(Sender : TObject);
begin
  if Notebook1.PageIndex>=0 then
    Notebook1.Pages[Notebook1.PageIndex] := 'Test';
end;

var
  F1: TForm1;

begin
  DebugLN('------ INIT ------- ');
  Application.Initialize;
  DebugLN('------ CREATE ------- ');
  Application.CreateForm(TForm1, F1);
  DebugLN('------ RUN ------- ');
  Application.Run;
  DebugLN('------ DONE ------- ');
end.