-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrmLockingProcesses.pas
More file actions
116 lines (102 loc) · 3.15 KB
/
frmLockingProcesses.pas
File metadata and controls
116 lines (102 loc) · 3.15 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
unit frmLockingProcesses;
interface
uses
System.SysUtils, System.Classes, Vcl.Forms, Vcl.StdCtrls, Vcl.ExtCtrls,
Vcl.Controls, Vcl.CheckLst, System.Generics.Collections;
type
TfrmLockingProcesses = class
public
class function ConfirmClose(const ProcessItems: TArray<string>): Boolean;
end;
implementation
class function TfrmLockingProcesses.ConfirmClose(const ProcessItems: TArray<string>): Boolean;
var
i: Integer;
Form: TForm;
pnlTop, pnlBottom: TPanel;
lblInfo: TLabel;
clbProcs: TCheckListBox;
btnCloseAll, btnManual: TButton;
begin
Result := False;
while True do
begin
Form := TForm.CreateNew(nil);
try
Form.Caption := '占用进程列表';
Form.Width := 560;
Form.Height := 460;
Form.Position := poScreenCenter;
Form.BorderStyle := bsDialog;
pnlTop := TPanel.Create(Form);
pnlTop.Parent := Form;
pnlTop.Align := alTop;
pnlTop.Height := 80;
lblInfo := TLabel.Create(Form);
lblInfo.Parent := pnlTop;
lblInfo.Align := alClient;
lblInfo.Caption := '以下进程正在占用将要迁移/删除的文件或目录:' + sLineBreak +
'请保持全部勾选并点击“关闭全部并继续”。' + sLineBreak +
'如不希望自动关闭,请点击“我将手动关闭后重试”。';
lblInfo.WordWrap := True;
clbProcs := TCheckListBox.Create(Form);
clbProcs.Parent := Form;
clbProcs.Align := alClient;
pnlBottom := TPanel.Create(Form);
pnlBottom.Parent := Form;
pnlBottom.Align := alBottom;
pnlBottom.Height := 50;
btnCloseAll := TButton.Create(Form);
btnCloseAll.Parent := pnlBottom;
btnCloseAll.Caption := '关闭全部并继续';
btnCloseAll.Left := pnlBottom.Width - 220;
btnCloseAll.Top := 10;
btnCloseAll.Width := 130;
btnCloseAll.Anchors := [akRight, akTop];
btnCloseAll.ModalResult := mrOk;
btnManual := TButton.Create(Form);
btnManual.Parent := pnlBottom;
btnManual.Caption := '我将手动关闭后重试';
btnManual.Left := pnlBottom.Width - 360;
btnManual.Top := 10;
btnManual.Width := 130;
btnManual.Anchors := [akRight, akTop];
btnManual.ModalResult := mrCancel;
clbProcs.Items.BeginUpdate;
try
for i := 0 to High(ProcessItems) do
begin
clbProcs.Items.Add(ProcessItems[i]);
clbProcs.Checked[i] := True;
end;
finally
clbProcs.Items.EndUpdate;
end;
if Form.ShowModal = mrOk then
begin
var AllChecked := True;
for i := 0 to clbProcs.Items.Count - 1 do
if not clbProcs.Checked[i] then
begin
AllChecked := False;
Break;
end;
if AllChecked then
begin
Result := True;
Exit;
end
else
MessageDlg('为保证操作一致性,请保持全部进程勾选。您也可以选择“我将手动关闭后重试”。', mtWarning, [mbOK], 0);
end
else
begin
Result := False;
Exit;
end;
finally
Form.Free;
end;
end;
end;
end.