File: test2_3twosimpleforms1.lpr

package info (click to toggle)
lazarus 4.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 275,760 kB
  • sloc: pascal: 2,341,904; xml: 509,420; makefile: 348,726; cpp: 93,608; sh: 3,387; java: 609; perl: 297; sql: 222; ansic: 137
file content (279 lines) | stat: -rw-r--r-- 9,078 bytes parent folder | download | duplicates (8)
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
{
 *****************************************************************************
 *                                                                           *
 *  This file is part of the Lazarus Component Library (LCL)                 *
 *                                                                           *
 *  See the file COPYING.LCL, included in this distribution,                 *
 *  for details about the copyright.                                         *
 *                                                                           *
 *  This program 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.                     *
 *                                                                           *
 *****************************************************************************
 
  LCL Test 2_3

  Showing a form at 100,90,350,200
}
program Test2_3TwoSimpleForms1;

{$mode objfpc}{$H+}

uses
  Interfaces, FPCAdds, LCLProc, LCLType, Classes, Controls, Forms, TypInfo,
  LMessages;

type

  { TForm1And2 }

  TForm1And2 = class(TForm)
    procedure FormActivate(Sender: TObject);
    procedure FormChangeBounds(Sender: TObject);
    procedure FormClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
    procedure FormCreate(Sender: TObject);
    procedure FormDeactivate(Sender: TObject);
    procedure FormEnter(Sender: TObject);
    procedure FormExit(Sender: TObject);
    function FormHelp(Command: Word; Data: PtrInt; var CallHelp: Boolean
      ): Boolean;
    procedure FormHide(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure FormKeyPress(Sender: TObject; var Key: char);
    procedure FormMouseDown(Sender: TOBject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormMouseEnter(Sender: TObject);
    procedure FormMouseLeave(Sender: TObject);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer
      );
    procedure FormMouseUp(Sender: TOBject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormMouseWheel(Sender: TObject; Shift: TShiftState;
      WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
    procedure FormMouseWheelDown(Sender: TObject; Shift: TShiftState;
      MousePos: TPoint; var Handled: Boolean);
    procedure FormMouseWheelUp(Sender: TObject; Shift: TShiftState;
      MousePos: TPoint; var Handled: Boolean);
    procedure FormPaint(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure FormShortcut(var Msg: TLMKey; var Handled: Boolean);
    procedure FormShow(Sender: TObject);
    procedure FormUTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
  public
    constructor Create(TheOwner: TComponent); override;
  end;

var
  Form1: TForm1And2 = nil;
  Form2: TForm1And2 = nil;

{ TForm1And2 }

procedure TForm1And2.FormActivate(Sender: TObject);
begin
  debugln('TForm1And2.FormActivate ',DbgSName(Sender));
end;

procedure TForm1And2.FormChangeBounds(Sender: TObject);
begin
  debugln('TForm1And2.FormChangeBounds ',DbgSName(Sender),' Bounds=',dbgs(BoundsRect));
end;

procedure TForm1And2.FormClick(Sender: TObject);
begin
  debugln('TForm1And2.FormClick ',DbgSName(Sender));
end;

procedure TForm1And2.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
  debugln('TForm1And2.FormClose ',DbgSName(Sender),' CloseAction=',
          GetEnumName(TypeInfo(TCloseAction),ord(CloseAction)));
end;

procedure TForm1And2.FormCloseQuery(Sender: TObject; var CanClose: boolean);
begin
  debugln('TForm1And2.FormCloseQuery ',DbgSName(Sender),' CanClose',dbgs(CanClose));
end;

procedure TForm1And2.FormCreate(Sender: TObject);
begin
  debugln('TForm1And2.FormCreate ',DbgSName(Sender));
end;

procedure TForm1And2.FormDeactivate(Sender: TObject);
begin
  debugln('TForm1And2.FormDeactivate ',DbgSName(Sender));
end;

procedure TForm1And2.FormEnter(Sender: TObject);
begin
  debugln('TForm1And2.FormEnter ',DbgSName(Sender));
end;

procedure TForm1And2.FormExit(Sender: TObject);
begin
  debugln('TForm1And2.FormExit ',DbgSName(Sender));
end;

function TForm1And2.FormHelp(Command: Word; Data: PtrInt; var CallHelp: Boolean
  ): Boolean;
begin
  debugln('TForm1And2.FormHelp Command=',dbgs(Command),' Data=',HexStr(Cardinal(Data),8),' CallHelp=',dbgs(CallHelp));
  Result:=false;
end;

procedure TForm1And2.FormHide(Sender: TObject);
begin
  debugln('TForm1And2.FormHide ',DbgSName(Sender));
end;

procedure TForm1And2.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState
  );
begin
  Debugln('TForm1And2.FormKeyDown ',DbgSName(Sender),' Key=',dbgs(Key),
          ' Shift=',dbgs(Shift));
end;

procedure TForm1And2.FormKeyPress(Sender: TObject; var Key: char);
begin
  debugln('TForm1And2.FormKeyPress ',DbgSName(Sender),' Key=',DbgStr(Key));
end;

procedure TForm1And2.FormMouseDown(Sender: TOBject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  debugln('TForm1And2.FormMouseDown ',DbgSName(Sender),
    ' Button=',GetEnumName(TypeInfo(TMouseButton),ord(Button)),
    ' X=',dbgs(X),' Y=',dbgs(Y),' Shift=',dbgs(Shift));
end;

procedure TForm1And2.FormMouseEnter(Sender: TObject);
begin
  debugln('TForm1And2.FormMouseEnter ',DbgSName(Sender));
end;

procedure TForm1And2.FormMouseLeave(Sender: TObject);
begin
  debugln('TForm1And2.FormMouseLeave ',DbgSName(Sender));
end;

procedure TForm1And2.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  debugln('TForm1And2.FormMouseMove ',DbgSName(Sender),
    ' X=',dbgs(X),' Y=',dbgs(Y),' Shift=',dbgs(Shift));
end;

procedure TForm1And2.FormMouseUp(Sender: TOBject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  debugln('TForm1And2.FormMouseUp ',DbgSName(Sender),
    ' Button=',GetEnumName(TypeInfo(TMouseButton),ord(Button)),
    ' X=',dbgs(X),' Y=',dbgs(Y),' Shift=',dbgs(Shift));
end;

procedure TForm1And2.FormMouseWheel(Sender: TObject; Shift: TShiftState;
  WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
  debugln('TForm1And2.FormMouseWheel ',DbgSName(Sender),
    ' WheelDelta=',dbgs(WheelDelta),' MousePos=',dbgs(MousePos),
    ' Handled=',dbgs(Handled),' Shift=',dbgs(Shift));
end;

procedure TForm1And2.FormMouseWheelDown(Sender: TObject; Shift: TShiftState;
  MousePos: TPoint; var Handled: Boolean);
begin
  debugln('TForm1And2.FormMouseWheelDown ',DbgSName(Sender),
    ' MousePos=',dbgs(MousePos),
    ' Handled=',dbgs(Handled),' Shift=',dbgs(Shift));
end;

procedure TForm1And2.FormMouseWheelUp(Sender: TObject; Shift: TShiftState;
  MousePos: TPoint; var Handled: Boolean);
begin
  debugln('TForm1And2.FormMouseWheelUp ',DbgSName(Sender),
    ' MousePos=',dbgs(MousePos),
    ' Handled=',dbgs(Handled),' Shift=',dbgs(Shift));
end;

procedure TForm1And2.FormPaint(Sender: TObject);
begin
  debugln('TForm1And2.FormPaint ',DbgSName(Sender));
end;

procedure TForm1And2.FormResize(Sender: TObject);
begin
  debugln('TForm1And2.FormResize ',DbgSName(Sender),' Bounds=',dbgs(BoundsRect));
end;

procedure TForm1And2.FormShortcut(var Msg: TLMKey; var Handled: Boolean);
begin
  debugln('TForm1And2.FormShortcut Msg.CharCode=',dbgs(Msg.CharCode),
          ' Handled=',dbgs(Handled));
end;

procedure TForm1And2.FormShow(Sender: TObject);
begin
  debugln('TForm1And2.FormShow ',DbgSName(Sender));
end;

procedure TForm1And2.FormUTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
begin
  debugln('TForm1And2.FormUTF8KeyPress ',DbgSName(Sender),' UTF8Key="',DbgStr(UTF8Key),'"');
end;

constructor TForm1And2.Create(TheOwner: TComponent);
begin
  OnActivate:=@FormActivate;
  OnChangeBounds:=@FormChangeBounds;
  OnClick:=@FormClick;
  OnClose:=@FormClose;
  OnCloseQuery:=@FormCloseQuery;
  OnCreate:=@FormCreate;
  OnDeactivate:=@FormDeactivate;
  OnEnter:=@FormEnter;
  OnExit:=@FormExit;
  OnHelp:=@FormHelp;
  OnHide:=@FormHide;
  OnKeyDown:=@FormKeyDown;
  OnKeyDown:=@FormKeyDown;
  OnKeyPress:=@FormKeyPress;
  OnMouseDown:=@FormMouseDown;
  OnMouseEnter:=@FormMouseEnter;
  OnMouseLeave:=@FormMouseLeave;
  OnMouseMove:=@FormMouseMove;
  OnMouseUp:=@FormMouseUp;
  OnMouseWheel:=@FormMouseWheel;
  OnMouseWheelDown:=@FormMouseWheelDown;
  OnMouseWheelUp:=@FormMouseWheelUp;
  OnPaint:=@FormPaint;
  OnResize:=@FormResize;
  OnShortcut:=@FormShortcut;
  OnShow:=@FormShow;
  OnUTF8KeyPress:=@FormUTF8KeyPress;
  inherited Create(TheOwner);

  if Self=Form1 then
    Name:='Form1'
  else
    Name:='Form2';
  Caption:='Title '+Name;
  if Name='Form1' then
    SetBounds(100,90,350,200)
  else
    SetBounds(470,90,380,190);
end;

begin
  Application.Initialize;
  Application.CreateForm(TForm1And2,Form1);
  debugln('Form1.Bounds=',dbgs(Form1.BoundsRect));
  Application.CreateForm(TForm1And2,Form2);
  debugln('Form2.Bounds=',dbgs(Form2.BoundsRect));
  Form2.Show;
  Application.Run;
end.