1{ 2 ***************************************************************************** 3 * * 4 * This file is part of the Lazarus Component Library (LCL) * 5 * * 6 * See the file COPYING.LCL, included in this distribution, * 7 * for details about the copyright. * 8 * * 9 * This program is distributed in the hope that it will be useful, * 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * 12 * * 13 ***************************************************************************** 14 15 LCL Test 1_1 16 17 Showing a form at 0,0,320,240 18} 19program Test1_1SimpleForm1; 20 21{$mode objfpc}{$H+} 22 23uses 24 Interfaces, FPCAdds, LCLProc, LCLType, Classes, Controls, Forms, TypInfo, 25 LMessages; 26 27type 28 29 { TForm1 } 30 31 TForm1 = class(TForm) 32 procedure Form1Activate(Sender: TObject); 33 procedure Form1ChangeBounds(Sender: TObject); 34 procedure Form1Click(Sender: TObject); 35 procedure Form1Close(Sender: TObject; var CloseAction: TCloseAction); 36 procedure Form1CloseQuery(Sender: TObject; var CanClose: boolean); 37 procedure Form1Create(Sender: TObject); 38 procedure Form1Deactivate(Sender: TObject); 39 procedure Form1Enter(Sender: TObject); 40 procedure Form1Exit(Sender: TObject); 41 function Form1Help(Command: Word; Data: PtrInt; var CallHelp: Boolean 42 ): Boolean; 43 procedure Form1Hide(Sender: TObject); 44 procedure Form1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 45 procedure Form1KeyPress(Sender: TObject; var Key: char); 46 procedure Form1MouseDown(Sender: TOBject; Button: TMouseButton; 47 Shift: TShiftState; X, Y: Integer); 48 procedure Form1MouseEnter(Sender: TObject); 49 procedure Form1MouseLeave(Sender: TObject); 50 procedure Form1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer 51 ); 52 procedure Form1MouseUp(Sender: TOBject; Button: TMouseButton; 53 Shift: TShiftState; X, Y: Integer); 54 procedure Form1MouseWheel(Sender: TObject; Shift: TShiftState; 55 WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); 56 procedure Form1MouseWheelDown(Sender: TObject; Shift: TShiftState; 57 MousePos: TPoint; var Handled: Boolean); 58 procedure Form1MouseWheelUp(Sender: TObject; Shift: TShiftState; 59 MousePos: TPoint; var Handled: Boolean); 60 procedure Form1Paint(Sender: TObject); 61 procedure Form1Resize(Sender: TObject); 62 procedure Form1Shortcut(var Msg: TLMKey; var Handled: Boolean); 63 procedure Form1Show(Sender: TObject); 64 procedure Form1UTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char); 65 public 66 constructor Create(TheOwner: TComponent); override; 67 end; 68 69{ TForm1 } 70 71procedure TForm1.Form1Activate(Sender: TObject); 72begin 73 debugln('TForm1.Form1Activate ',DbgSName(Sender)); 74end; 75 76procedure TForm1.Form1ChangeBounds(Sender: TObject); 77begin 78 debugln('TForm1.Form1ChangeBounds ',DbgSName(Sender),' Bounds=',dbgs(BoundsRect)); 79end; 80 81procedure TForm1.Form1Click(Sender: TObject); 82begin 83 debugln('TForm1.Form1Click ',DbgSName(Sender)); 84end; 85 86procedure TForm1.Form1Close(Sender: TObject; var CloseAction: TCloseAction); 87begin 88 debugln('TForm1.Form1Close ',DbgSName(Sender),' CloseAction=', 89 GetEnumName(TypeInfo(TCloseAction),ord(CloseAction))); 90end; 91 92procedure TForm1.Form1CloseQuery(Sender: TObject; var CanClose: boolean); 93begin 94 debugln('TForm1.Form1CloseQuery ',DbgSName(Sender),' CanClose',dbgs(CanClose)); 95end; 96 97procedure TForm1.Form1Create(Sender: TObject); 98begin 99 debugln('TForm1.Form1Create ',DbgSName(Sender)); 100end; 101 102procedure TForm1.Form1Deactivate(Sender: TObject); 103begin 104 debugln('TForm1.Form1Deactivate ',DbgSName(Sender)); 105end; 106 107procedure TForm1.Form1Enter(Sender: TObject); 108begin 109 debugln('TForm1.Form1Enter ',DbgSName(Sender)); 110end; 111 112procedure TForm1.Form1Exit(Sender: TObject); 113begin 114 debugln('TForm1.Form1Exit ',DbgSName(Sender)); 115end; 116 117function TForm1.Form1Help(Command: Word; Data: PtrInt; var CallHelp: Boolean 118 ): Boolean; 119begin 120 debugln('TForm1.Form1Help Command=',dbgs(Command),' Data=',HexStr(Cardinal(Data),8),' CallHelp=',dbgs(CallHelp)); 121 Result:=false; 122end; 123 124procedure TForm1.Form1Hide(Sender: TObject); 125begin 126 debugln('TForm1.Form1Hide ',DbgSName(Sender)); 127end; 128 129procedure TForm1.Form1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState 130 ); 131begin 132 Debugln('TForm1.Form1KeyDown ',DbgSName(Sender),' Key=',dbgs(Key), 133 ' Shift=',dbgs(Shift)); 134end; 135 136procedure TForm1.Form1KeyPress(Sender: TObject; var Key: char); 137begin 138 debugln('TForm1.Form1KeyPress ',DbgSName(Sender),' Key=',DbgStr(Key)); 139end; 140 141procedure TForm1.Form1MouseDown(Sender: TOBject; Button: TMouseButton; 142 Shift: TShiftState; X, Y: Integer); 143begin 144 debugln('TForm1.Form1MouseDown ',DbgSName(Sender), 145 ' Button=',GetEnumName(TypeInfo(TMouseButton),ord(Button)), 146 ' X=',dbgs(X),' Y=',dbgs(Y),' Shift=',dbgs(Shift)); 147end; 148 149procedure TForm1.Form1MouseEnter(Sender: TObject); 150begin 151 debugln('TForm1.Form1MouseEnter ',DbgSName(Sender)); 152end; 153 154procedure TForm1.Form1MouseLeave(Sender: TObject); 155begin 156 debugln('TForm1.Form1MouseLeave ',DbgSName(Sender)); 157end; 158 159procedure TForm1.Form1MouseMove(Sender: TObject; Shift: TShiftState; X, 160 Y: Integer); 161begin 162 exit; 163 debugln('TForm1.Form1MouseMove ',DbgSName(Sender), 164 ' X=',dbgs(X),' Y=',dbgs(Y),' Shift=',dbgs(Shift)); 165end; 166 167procedure TForm1.Form1MouseUp(Sender: TOBject; Button: TMouseButton; 168 Shift: TShiftState; X, Y: Integer); 169begin 170 debugln('TForm1.Form1MouseUp ',DbgSName(Sender), 171 ' Button=',GetEnumName(TypeInfo(TMouseButton),ord(Button)), 172 ' X=',dbgs(X),' Y=',dbgs(Y),' Shift=',dbgs(Shift)); 173end; 174 175procedure TForm1.Form1MouseWheel(Sender: TObject; Shift: TShiftState; 176 WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); 177begin 178 debugln('TForm1.Form1MouseWheel ',DbgSName(Sender), 179 ' WheelDelta=',dbgs(WheelDelta),' MousePos=',dbgs(MousePos), 180 ' Handled=',dbgs(Handled),' Shift=',dbgs(Shift)); 181end; 182 183procedure TForm1.Form1MouseWheelDown(Sender: TObject; Shift: TShiftState; 184 MousePos: TPoint; var Handled: Boolean); 185begin 186 debugln('TForm1.Form1MouseWheelDown ',DbgSName(Sender), 187 ' MousePos=',dbgs(MousePos), 188 ' Handled=',dbgs(Handled),' Shift=',dbgs(Shift)); 189end; 190 191procedure TForm1.Form1MouseWheelUp(Sender: TObject; Shift: TShiftState; 192 MousePos: TPoint; var Handled: Boolean); 193begin 194 debugln('TForm1.Form1MouseWheelUp ',DbgSName(Sender), 195 ' MousePos=',dbgs(MousePos), 196 ' Handled=',dbgs(Handled),' Shift=',dbgs(Shift)); 197end; 198 199procedure TForm1.Form1Paint(Sender: TObject); 200begin 201 debugln('TForm1.Form1Paint ',DbgSName(Sender)); 202end; 203 204procedure TForm1.Form1Resize(Sender: TObject); 205begin 206 debugln('TForm1.Form1Resize ',DbgSName(Sender),' Bounds=',dbgs(BoundsRect)); 207end; 208 209procedure TForm1.Form1Shortcut(var Msg: TLMKey; var Handled: Boolean); 210begin 211 debugln('TForm1.Form1Shortcut Msg.CharCode=',dbgs(Msg.CharCode), 212 ' Handled=',dbgs(Handled)); 213end; 214 215procedure TForm1.Form1Show(Sender: TObject); 216begin 217 debugln('TForm1.Form1Show ',DbgSName(Sender)); 218end; 219 220procedure TForm1.Form1UTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char); 221begin 222 debugln('TForm1.Form1UTF8KeyPress ',DbgSName(Sender),' UTF8Key="',DbgStr(UTF8Key),'"'); 223end; 224 225constructor TForm1.Create(TheOwner: TComponent); 226begin 227 OnActivate:=@Form1Activate; 228 OnChangeBounds:=@Form1ChangeBounds; 229 OnClick:=@Form1Click; 230 OnClose:=@Form1Close; 231 OnCloseQuery:=@Form1CloseQuery; 232 OnCreate:=@Form1Create; 233 OnDeactivate:=@Form1Deactivate; 234 OnEnter:=@Form1Enter; 235 OnExit:=@Form1Exit; 236 OnHelp:=@Form1Help; 237 OnHide:=@Form1Hide; 238 OnKeyDown:=@Form1KeyDown; 239 OnKeyDown:=@Form1KeyDown; 240 OnKeyPress:=@Form1KeyPress; 241 OnMouseDown:=@Form1MouseDown; 242 OnMouseEnter:=@Form1MouseEnter; 243 OnMouseLeave:=@Form1MouseLeave; 244 OnMouseMove:=@Form1MouseMove; 245 OnMouseUp:=@Form1MouseUp; 246 OnMouseWheel:=@Form1MouseWheel; 247 OnMouseWheelDown:=@Form1MouseWheelDown; 248 OnMouseWheelUp:=@Form1MouseWheelUp; 249 OnPaint:=@Form1Paint; 250 OnResize:=@Form1Resize; 251 OnShortcut:=@Form1Shortcut; 252 OnShow:=@Form1Show; 253 OnUTF8KeyPress:=@Form1UTF8KeyPress; 254 inherited Create(TheOwner); 255 256 Name:='Form1'; 257 Caption:='Title Form1'; 258 SetBounds(100,90,350,200); 259end; 260 261var 262 Form1: TForm1 = nil; 263begin 264 Application.Initialize; 265 Application.CreateForm(TForm1,Form1); 266 debugln('Form1.Bounds=',dbgs(Form1.BoundsRect)); 267 Application.Run; 268end. 269 270