/[projects]/dao/DelphiScanner/Components/tpsystools_4.04/examples/Delphi/Observer.pas
ViewVC logotype

Contents of /dao/DelphiScanner/Components/tpsystools_4.04/examples/Delphi/Observer.pas

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2671 - (show annotations) (download)
Tue Aug 25 18:15:15 2015 UTC (8 years, 9 months ago) by torben
File size: 3378 byte(s)
Added tpsystools component
1 (* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is TurboPower SysTools
15 *
16 * The Initial Developer of the Original Code is
17 * TurboPower Software
18 *
19 * Portions created by the Initial Developer are Copyright (C) 1996-2002
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * ***** END LICENSE BLOCK ***** *)
25
26 unit Observer;
27
28 interface
29
30 uses
31 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
32 StdCtrls, StPtrns, ExtCtrls;
33
34
35 type
36 TObserverForm = class(TForm)
37 Panel1: TPanel;
38 Button1: TButton;
39 Edit1: TEdit;
40 Label1: TLabel;
41 Button2: TButton;
42 Button3: TButton;
43 Button4: TButton;
44 procedure Edit1Change(Sender: TObject);
45 procedure Button1Click(Sender: TObject);
46 procedure Button2Click(Sender: TObject);
47 procedure Button3Click(Sender: TObject);
48 procedure Button4Click(Sender: TObject);
49 procedure FormCreate(Sender: TObject);
50 procedure FormDestroy(Sender: TObject);
51 private
52 // Code for the observer
53
54 { Private declarations }
55 public
56 TheObserver: TStObserver;
57
58 procedure ReceiveNotification1(WhatChanged: TObject);
59 procedure ReceiveNotification2(WhatChanged: TObject);
60 procedure ReceiveNotification3(WhatChanged: TObject);
61 procedure ReceiveNotification4(WhatChanged: TObject);
62 { Public declarations }
63 end;
64
65
66 var
67 ObserverForm: TObserverForm;
68
69 implementation
70
71 {$R *.DFM}
72
73 procedure TObserverForm.Edit1Change(Sender: TObject);
74 begin
75 TheObserver.Notify(TObject(Edit1.Text));
76 end;
77
78 procedure TObserverForm.ReceiveNotification1(WhatChanged: TObject);
79 begin
80 Button1.Caption := String(WhatChanged);
81 end;
82
83 procedure TObserverForm.ReceiveNotification2(WhatChanged: TObject);
84 begin
85 Button2.Caption := String(WhatChanged);
86 end;
87
88 procedure TObserverForm.ReceiveNotification3(WhatChanged: TObject);
89 begin
90 Button3.Caption := String(WhatChanged);
91 end;
92
93 procedure TObserverForm.ReceiveNotification4(WhatChanged: TObject);
94 begin
95 Button4.Caption := String(WhatChanged);
96 end;
97
98 procedure TObserverForm.Button1Click(Sender: TObject);
99 begin
100 Edit1.Text:= 'Reset 1';
101 end;
102
103 procedure TObserverForm.Button2Click(Sender: TObject);
104 begin
105 Edit1.Text:= 'Reset 2';
106 end;
107
108 procedure TObserverForm.Button3Click(Sender: TObject);
109 begin
110 Edit1.Text:= 'Reset 3';
111 end;
112
113 procedure TObserverForm.Button4Click(Sender: TObject);
114 begin
115 Edit1.Text:= 'Reset 4';
116 end;
117
118 procedure TObserverForm.FormCreate(Sender: TObject);
119 begin
120 TheObserver := TStObserver.Create;
121 TheObserver.Add(ReceiveNotification1);
122 TheObserver.Add(ReceiveNotification2);
123 TheObserver.Add(ReceiveNotification3);
124 TheObserver.Add(ReceiveNotification4);
125 end;
126
127 procedure TObserverForm.FormDestroy(Sender: TObject);
128 begin
129 TheObserver.Free;
130 end;
131
132 end.

  ViewVC Help
Powered by ViewVC 1.1.20