-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnt_BaseIni.pas
More file actions
412 lines (378 loc) · 10.9 KB
/
Copy pathUnt_BaseIni.pas
File metadata and controls
412 lines (378 loc) · 10.9 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
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
unit Unt_BaseIni;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ToolWin, ActnMan, ActnCtrls, ActnMenus, Menus, ActnList, dxSkinsCore,
dxSkinBlack, dxSkinBlue, dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee,
dxSkinDarkRoom, dxSkinDarkSide, dxSkinDevExpressDarkStyle,
dxSkinDevExpressStyle, dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast,
dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky,
dxSkinMcSkin, dxSkinMoneyTwins, dxSkinOffice2007Black, dxSkinOffice2007Blue,
dxSkinOffice2007Green, dxSkinOffice2007Pink, dxSkinOffice2007Silver,
dxSkinOffice2010Black, dxSkinOffice2010Blue, dxSkinOffice2010Silver,
dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus,
dxSkinSilver, dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008,
dxSkinTheAsphaltWorld, dxSkinsDefaultPainters, dxSkinValentine, dxSkinVS2010,
dxSkinWhiteprint, dxSkinXmas2008Blue, dxSkinscxPCPainter, cxGraphics,
cxControls, cxLookAndFeels, cxLookAndFeelPainters, dxSkinsForm, cxPC,
StdCtrls, cxButtons, ExtCtrls, dxGDIPlusClasses, ImgList, ShellApi, Unt_Util,
Unt_Sobre, Unt_UpDown, dxScreenTip, dxCustomHint, cxHint, MidasLib, Registry,
dxAlertWindow, DB, DBClient;
type
TTypWinBits = (Bit32, Bit64);
TF_BaseIni = class(TForm)
act_Cadastros: TActionList;
act_CadEmpresa: TAction;
act_CadClientes: TAction;
act_CadDocumentos: TAction;
act_Sair: TAction;
act_EmiProtocolos: TAction;
act_RelClientes: TAction;
act_RelProtocolos: TAction;
act_RelDocumentos: TAction;
pgctrl_base: TcxPageControl;
ts_base: TcxTabSheet;
skin_base: TdxSkinController;
pnl_menu: TPanel;
btn_cadastro: TcxButton;
pm_cadastros: TPopupMenu;
mni_act_CadEmpresa: TMenuItem;
mni_act_CadClientes: TMenuItem;
mni_act_CadDocumentos: TMenuItem;
mniN2: TMenuItem;
mni_act_Sair: TMenuItem;
pm_rotinas: TPopupMenu;
mni_act_EmiProtocolos: TMenuItem;
pm_relatorios: TPopupMenu;
mni_act_RelClientes: TMenuItem;
mni_act_RelProtocolos: TMenuItem;
mni_act_RelDocumentos: TMenuItem;
pm_ferramentas: TPopupMenu;
btn_rotinas: TcxButton;
btn_relatorios: TcxButton;
btn_ferramentas: TcxButton;
ac_CadUsuarios: TAction;
acCadUsuarios1: TMenuItem;
ac_CadSetores: TAction;
Cadastrodesetores1: TMenuItem;
img_base: TImage;
pm_try: TPopupMenu;
mni_Cadastros: TMenuItem;
Cadastrodaempresa1: TMenuItem;
Cadastrodeusuarios1: TMenuItem;
Cadastrodesetores2: TMenuItem;
Cadastrodedocumentos1: TMenuItem;
Cadastrodeclientes1: TMenuItem;
Fecharaplicao1: TMenuItem;
N2: TMenuItem;
tm_sobre: TTimer;
hint_base: TcxHintStyleController;
act_Sobre: TAction;
act_AgendaCompromisso: TAction;
Agendadecompromissos2: TMenuItem;
N3: TMenuItem;
Sobreaaplicao1: TMenuItem;
ac_IniciarWindows: TAction;
N1: TMenuItem;
Ferramentas1: TMenuItem;
Agendadecompromissos1: TMenuItem;
N4: TMenuItem;
Iniciaraplicaocomowindows1: TMenuItem;
ac_CaixaCliente: TAction;
Caixadocliente1: TMenuItem;
Caixadocliente2: TMenuItem;
act_ArquivoCliente: TAction;
Arquivodocliente1: TMenuItem;
act_AgendaCompCad: TAction;
alerta_base: TdxAlertWindowManager;
imgLst_base: TImageList;
cds_Compromissos: TClientDataSet;
ilLst_BotoesMess: TImageList;
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure act_SairExecute(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure btn_moverMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure img_baseMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btn_cadastroMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure btn_cadastroMouseLeave(Sender: TObject);
procedure tm_sobreTimer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure act_SobreExecute(Sender: TObject);
procedure act_AgendaCompromissoExecute(Sender: TObject);
procedure ac_IniciarWindowsExecute(Sender: TObject);
procedure ac_CaixaClienteExecute(Sender: TObject);
private
{ Private declarations }
//procedure WMSysCommand(var Msg: TWMSysCommand); Message WM_SysCommand;
procedure WMTrayIcon(var Msg: TMessage); Message WM_TRAYICON;
procedure DestroyIcone;
procedure CriaIcone;
function WinBits: TTypWinBits;
function CreateConnection: TRegistry;
procedure RunAdd(aDesc, aName: string);
public
{ Public declarations }
protected
procedure CreateParams(var Params: TCreateParams); override;
end;
var
F_BaseIni: TF_BaseIni;
implementation
{$R *.dfm}
procedure TF_BaseIni.RunAdd(aDesc, aName: string);
var
Reg: TRegistry;
sRegKey: String;
begin
sRegKey := 'Software\Microsoft\Windows\CurrentVersion\Run';
Reg := CreateConnection;
with Reg do
begin
try
RootKey := HKEY_LOCAL_MACHINE;
if not KeyExists(sRegKey) then
OpenKey(sRegKey, True)
else
OpenKey(sRegKey, False);
WriteString(aDesc, aName);
finally
CloseKey;
Free;
end;
end;
end;
function TF_BaseIni.CreateConnection: TRegistry;
begin
Result := TRegistry.Create;
try
case WinBits of
Bit32: Result := TRegistry.Create;
Bit64: Result := TRegistry.Create(KEY_WRITE OR KEY_WOW64_64KEY);
end;
except
on E: exception do
Result := nil;
end;
end;
function TF_BaseIni.WinBits: TTypWinBits;
type
TIsWow64Process = function(Handle:THandle; var IsWow64 : BOOL) : BOOL; stdcall;
var
hKernel32 : Integer;
IsWow64Process : TIsWow64Process;
IsWow64 : BOOL;
begin
Result := Bit32;
hKernel32 := LoadLibrary('kernel32.dll');
if (hKernel32 = 0) then RaiseLastOSError;
@IsWow64Process := GetProcAddress(hkernel32, 'IsWow64Process');
if Assigned(IsWow64Process) then
begin
IsWow64 := False;
if (IsWow64Process(GetCurrentProcess, IsWow64)) then
Result := Bit64
else
RaiseLastOSError;
end;
FreeLibrary(hKernel32);
end;
procedure TF_BaseIni.act_AgendaCompromissoExecute(Sender: TObject);
begin
if F_Sobre <> nil then
F_Sobre.tab_Calendario.Show;
end;
procedure TF_BaseIni.act_SairExecute(Sender: TObject);
begin
Close;
end;
procedure TF_BaseIni.act_SobreExecute(Sender: TObject);
begin
if F_Sobre <> nil then
F_Sobre.ts_sobre.Show;
end;
procedure TF_BaseIni.ac_CaixaClienteExecute(Sender: TObject);
begin
if F_Sobre <> nil then
F_Sobre.ts_CaixaCliente.Show;
end;
procedure TF_BaseIni.ac_IniciarWindowsExecute(Sender: TObject);
var
S: string;
begin
try
S:=ExtractFileDir(Application.ExeName)+'\'+ExtractFileName(Application.ExeName);
RunAdd('Protocollo', S);
except
MessageDlg('Não foi possivel alterar o registro do windows', mtInformation, [mbOK], 0);
end;
end;
procedure TF_BaseIni.btn_cadastroMouseLeave(Sender: TObject);
begin
Self.AlphaBlendValue:= 200;
end;
procedure TF_BaseIni.btn_cadastroMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
Self.AlphaBlendValue:= 255;
end;
procedure TF_BaseIni.btn_moverMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
const
sc_DragMove = $f012;
begin
ReleaseCapture;
Perform(wm_SysCommand, sc_DragMove, 0);
end;
procedure TF_BaseIni.CreateParams(var Params: TCreateParams);
begin
SetWindowLong( Application.Handle, Gwl_ExStyle, Ws_Ex_ToolWindow );
BorderStyle := bsNone;
inherited CreateParams(Params);
Params.Style := (Params.Style or WS_POPUP) and not WS_CAPTION;
end;
procedure TF_BaseIni.CriaIcone;
var
NotifyIconData: TNotifyIconData;
begin
with NotifyIconData do
begin
cbSize:= SizeOf(TNotifyIconData);
Wnd:= Self.Handle;
uID:= 0;
uCallbackMessage:= WM_TRAYICON;
uFlags:= NIF_ICON or NIF_TIP or NIF_MESSAGE;
hIcon:= Application.Icon.Handle;
szTip:= 'Protocollo';
end;
Shell_NotifyIcon(NIM_ADD, @NotifyIconData);
Application.ShowMainForm:= False;
end;
procedure TF_BaseIni.DestroyIcone;
var
NotifyIconData: TNotifyIconData;
begin
with NotifyIconData do
begin
cbSize:= SizeOf(TNotifyIconData);
Wnd:= Self.Handle;
uID:= 0;
uFlags:= 0;
end;
Shell_NotifyIcon(NIM_DELETE, @NotifyIconData);
end;
procedure TF_BaseIni.FormClose(Sender: TObject; var Action: TCloseAction);
begin
DestroyIcone;
end;
procedure TF_BaseIni.FormCreate(Sender: TObject);
begin
F_Sobre:= TF_Sobre.Create(Self);
with F_Sobre do
begin
Left:= Self.Left;
Top:= Self.Top + Self.Height + 2;
end;
F_UpDown:= TF_UpDown.Create(Self);
with F_UpDown do
begin
F_UpDown.OutHandle:= F_Sobre.Handle;
Left:= (Self.BoundsRect.Right) - (F_UpDown.Width);
Top:= F_Sobre.Top + F_Sobre.Height;
end;
end;
procedure TF_BaseIni.FormKeyPress(Sender: TObject; var Key: Char);
begin
If key = #13 then
Begin
Key:= #0;
Perform(Wm_NextDlgCtl,0,0);
End;
end;
procedure TF_BaseIni.FormShow(Sender: TObject);
var
Reg: TRegistry;
S: string;
begin
CriaIcone;
Left:= Screen.Width - Width;
Top:= 0;
tm_sobre.Enabled:= True;
ShowWindow(Application.Handle, SW_HIDE);
Reg := TRegistry.Create;
try
S:=ExtractFileDir(Application.ExeName)+'\'+ExtractFileName(Application.ExeName);
Reg.rootkey:=HKEY_LOCAL_MACHINE;
Reg.Openkey('SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN',false);
ac_IniciarWindows.Checked:= Reg.ReadString('Protocollo') = S;
Reg.closekey;
finally
Reg.Free;
end;
end;
procedure TF_BaseIni.img_baseMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
const
sc_DragMove = $f012;
begin
ReleaseCapture;
Perform(wm_SysCommand, sc_DragMove, 0);
end;
procedure TF_BaseIni.tm_sobreTimer(Sender: TObject);
begin
with F_Sobre do
begin
Left:= Self.Left;
Top:= Self.Top + Self.Height + 2;
if not Showing then
Show;
end;
with F_UpDown do
begin
F_UpDown.OutHandle:= F_Sobre.Handle;
Left:= (Self.BoundsRect.Right) - (F_UpDown.Width);
if F_Sobre.Height = 0 then
Top:= Self.Top + Self.Height
else
Top:= F_Sobre.Top + F_Sobre.Height;
if not Showing then
Show;
end;
end;
//procedure TF_BaseIni.WMSysCommand(var Msg: TWMSysCommand);
//begin
// case (Msg.CmdType) of
// SC_MINIMIZE:
// begin
// Self.Visible:= False;
// CriaIcone;
// end;
// SC_MAXIMIZE:
// begin
// Self.Visible:= True;
// end
// else
// Inherited;
// end;
//end;
procedure TF_BaseIni.WMTrayIcon(var Msg: TMessage);
var
Pt: TPoint;
begin
if (Msg.LParam = WM_RBUTTONDOWN) then
begin
GetCursorPos(Pt);
pm_try.Popup(Pt.X, Pt.Y);
pm_try.AutoPopup:= False;
end
// else
// if (Msg.LParam = WM_LBUTTONDBLCLK) then
// begin
// Self.Visible:= True;
// DestroyIcone;
// end;
end;
end.