-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnit1.pas
More file actions
85 lines (69 loc) · 1.7 KB
/
Unit1.pas
File metadata and controls
85 lines (69 loc) · 1.7 KB
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
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
Vcl.Direct2D, Winapi.D2D1, Vcl.ExtCtrls, Vcl.Imaging.pngimage,
System.DateUtils, System.Types,
DirectPaintBox, DataGenerator;
type
TForm1 = class(TForm)
img1: TImage;
procedure FormDestroy(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
private
{ Private declarations }
FPaintBox: TDirectPaintBox;
FDataGeneratorThread: TDataGeneratorThread;
procedure FreeDataGeneratorThread;
procedure CreatePaintBox;
protected
procedure CreateWnd; override;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.CreateWnd;
begin
inherited CreateWnd;
CreatePaintBox;
end;
procedure TForm1.CreatePaintBox;
begin
FPaintBox := TDirectPaintBox.Create(Self);
FPaintBox.Parent := Self;
FPaintBox.Align := alClient;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FreeDataGeneratorThread;
end;
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_SPACE then
begin
FreeDataGeneratorThread;
FDataGeneratorThread := TDataGeneratorThread.Create(img1.Picture.Graphic, FPaintBox);
FDataGeneratorThread.Priority := tpTimeCritical;
end
else
if Key = VK_ESCAPE then
begin
FreeDataGeneratorThread;
end;
end;
procedure TForm1.FreeDataGeneratorThread;
begin
if Assigned(FDataGeneratorThread) then
begin
FDataGeneratorThread.Terminate;
FDataGeneratorThread.WaitFor;
FreeAndNil(FDataGeneratorThread);
end;
end;
end.