-
Notifications
You must be signed in to change notification settings - Fork 0
/
Unit2.pas
205 lines (159 loc) · 4.2 KB
/
Unit2.pas
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
unit Unit2;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Mirror;
type
TForm2 = class(TForm)
Memo1: TMemo;
Button3: TButton;
Button4: TButton;
Button1: TButton;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
Label1: TLabel;
Label2: TLabel;
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure CheckBox3Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
private
{ Private declarations }
public
mn: TMirrorDrawer;
{ Public declarations }
end;
var
Form2: TForm2;
PrmMonitor: Tmonitor;
SecMonitor: Tmonitor;
implementation
{$R *.dfm}
uses Unit1;
procedure TForm2.FormCreate(Sender: TObject);
var
i: integer;
flagchar: string;
begin
mn := nil;
PrmMonitor := nil;
SecMonitor := nil;
for I := 0 to Screen.MonitorCount - 1 do
begin
flagchar := ' ';
if not(Screen.Monitors[i].Primary) then
begin
if (SecMonitor = nil) then
begin
SecMonitor := Screen.Monitors[i];
flagchar := '(S)';
end;
end
else
flagchar := '(P)';
Memo1.Lines.Add('Mon' + inttostr(Screen.Monitors[i].MonitorNum) + flagchar +
' X:' + inttostr(Screen.Monitors[i].Left) + #9'Y:' +
inttostr(Screen.Monitors[i].Top) + #9'W:' +
inttostr(Screen.Monitors[i].Width) + #9'H:' +
inttostr(Screen.Monitors[i].Height))
end;
PrmMonitor := Screen.PrimaryMonitor;
mn := TMirrorDrawer.Create(PrmMonitor, SecMonitor); // PrmMonitor
end;
procedure TForm2.FormDestroy(Sender: TObject);
begin
mn.Terminate;
end;
procedure TForm2.FormShow(Sender: TObject);
begin
with PrmMonitor do
begin
self.Left := Left + (Width div 2) - (self.Width div 2);
self.Top := Top + (Height div 2) - (self.Height div 2)
end
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
mn.Suspend;
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
{
if( assigned(mn)) then begin
mn.Terminate;
freeandnil(mn);
end; }
mn.Resume;
// bmp.Free;
end;
procedure TForm2.Button4Click(Sender: TObject);
var
mindex: integer;
begin
// PrmMonitor:=nil;
// SecMonitor:=nil;
mn.UseHalfTone := CheckBox2.Checked;
if Screen.MonitorCount > 1 then
begin
with SecMonitor do
begin
// Form1.left := left +(width div 2) -(Form1.width div 2);
// Form1.top := top +(height div 2) -(Form1.height div 2);
Form1.Show;
Form1.Left := Left + (Width div 2) - (Form1.Width div 2);
Form1.Top := Top + (Height div 2) - (Form1.Height div 2);
Form1.WindowState := wsMaximized;
mn.Resume;
end
end
else
begin
Form1.Show;
mn.Resume;
end;
label1.Caption:='Active';
label1.Font.Color:=clgreen;
end;
procedure TForm2.CheckBox1Click(Sender: TObject);
begin
mn.IncludeMouse := CheckBox1.Checked;
CheckBox1.Invalidate;
CheckBox1.repaint;
end;
procedure TForm2.CheckBox2Click(Sender: TObject);
begin
if( Assigned(mn)) then mn.UseHalfTone:=(sender as tcheckbox).checked;
end;
procedure TForm2.CheckBox3Click(Sender: TObject);
begin
if( Assigned(mn)) then mn.VerticalInvert:=(sender as tcheckbox).checked;
end;
{
procedure swapbmp(bmp: Tbitmap);
var
b: Tbitmap;
X, Y: Integer;
SrcRect, DstRect: TRect;
begin
// Assumes that Image1 holds the bitmap to be flipped
X := bmp.Width;
Y := bmp.Height;
SrcRect := Rect(0, 0, X, Y);
DstRect := Rect(X, 0, 0, Y); // <===== Mark this !!!
b := Tbitmap.Create();
b.Width := X;
b.Height := Y;
// DummyImage.Canvas.CopyMode := cmSrcCopy
b.Canvas.CopyRect(DstRect, bmp.Canvas, SrcRect);
// Write it back to the original bitmap
bmp.Assign(b);
b.Free;
end; }
end.