-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtasklst.pas
158 lines (142 loc) · 4.13 KB
/
tasklst.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
unit TaskLst;
(******
Task List unit
Based on:
Task List plugin
Copyright (C) 2002 Aleksej Kozlov (Cat)
2:5030/1326.13
******)
{JO: 20-10-2002 ¯¥à¥¤¥« « ¨§ ¯« £¨ ¢ ¬®¤ã«ì ¤«ï ª®¬¯¨«ï樨 ¢ ï¤à¥ DN/2 , }
{ ¤®¡ ¢«¥ë áâனª¨ ShowExePaths ¨ KillAllowed ¢ dn.ini , }
{ ¢ OS/2 ¢¥àᨨ ¤®¡ ¢«¥ ¯®ª § ⨯ á¥áᨨ, ¯®ª § § £®«®¢ª ®ª }
{ (âॡã¥â PM) ¨ ¢®§¬®¦®áâì ¯¥à¥ª«îç¥¨ï ®ª® ¯à®æ¥áá (âॡã¥â PM) }
{&Delphi+}
{&Use32+}
interface
uses
{$IFDEF OS2}Proc_Os2, {$ENDIF}
{$IFDEF WIN32}Proc_W32, {$ENDIF}
Defines, Objects, Views, Drivers, Dialogs
;
const
cmButton1 = 65535;
type
PProcessList = ^TProcessList;
TProcessList = object(TListBox)
function GetText(Item: Integer; MaxLen: Integer): String; virtual;
end;
PProcessDialog = ^TProcessDialog;
TProcessDialog = object(TDialog)
ListBox: PProcessList;
constructor Init(Collection: PProcessCollection);
procedure HandleEvent(var Event: TEvent); virtual;
end;
procedure InsertTaskList;
implementation
uses
DNApp, Commands, DnIni, DNHelp
;
function TProcessList.GetText(Item: Integer; MaxLen: Integer): String;
begin
GetText := PProcessItem(List^.At(Item))^.GetString;
end;
constructor TProcessDialog.Init(Collection: PProcessCollection);
var
R: TRect;
HScrollBar: PScrollBar;
VScrollBar: PScrollBar;
X1, Y1: Byte;
I: LongInt;
begin
X1 := ScreenWidth-4;
Y1 := ScreenHeight-5;
if Collection^.Count < (Y1-4) then
Y1 := Collection^.Count+4;
if Y1 < 10 then
Y1 := 10;
{Cat:warn ¢ í⮬ ¬¥á⥠¢®§¨ªã⠯஡«¥¬ë, ¥á«¨ ¯®áâ ¢¨âì ᫨誮¬ ¬ «¥ìª¨¥ à §¬¥àë íªà }
R.Assign(0, 0, X1, Y1);
TDialog.Init(R, GetString(dlTasklist));
Options := Options or ofCentered;
R.Assign(X1-13, 3, X1-2, 5);
Insert(New(PButton, Init(R, GetString(dlSwitchButton), cmOK,
bfDefault)));
R.Assign(X1-13, 5, X1-2, 7);
if KillAllowed then
begin
Insert(New(PButton, Init(R, GetString(dlKillButton), cmButton1,
bfNormal)));
R.Assign(X1-13, 7, X1-2, 9);
end;
Insert(New(PButton, Init(R, GetString(dlCancelButton), cmCancel,
bfNormal)));
R.Assign(X1-14, 2, X1-13, Y1-2);
VScrollBar := New(PScrollBar, Init(R));
Insert(VScrollBar);
R.Assign(2, Y1-2, X1-14, Y1-1);
HScrollBar := New(PScrollBar, Init(R));
Insert(HScrollBar);
with HScrollBar^ do
begin
Options := Options or ofPreProcess;
SetRange(1, 128);
SetStep(X1-15, 1);
end;
R.Assign(2, 2, X1-14, Y1-2);
ListBox := New(PProcessList, Init(R, 1, VScrollBar));
ListBox^.HScrollBar := HScrollBar;
ListBox^.NewLisT(PCollection(Collection));
Insert(ListBox);
{$IFDEF OS2} {JO: ¢ Win32 ¯®ª ¥ ¤®¤¥« ®}
I := 0;
while (I < Collection^.Count) and
(PProcessItem(Collection^.At(I))^.Pid < GetCurPid)
do
Inc(I);
if I >= Collection^.Count then
I := 0;
VScrollBar^.SetValue(I);
{$ENDIF}
HelpCtx := hcTaskList;
end { TProcessDialog.Init };
procedure TProcessDialog.HandleEvent(var Event: TEvent);
begin
if (Event.What = evCommand) and (Event.Command = cmButton1)
or (Event.What = evKeyDown) and (Event.KeyCode = kbDel)
then
EndModal(cmButton1);
inherited HandleEvent(Event);
end;
procedure InsertTaskList;
var
Collection: PProcessCollection;
Dialog: PProcessDialog;
label Ret;
begin
Collection := GetProcessList;
Dialog := New(PProcessDialog, Init(Collection));
Ret:
case Desktop^.ExecView(Dialog) of
cmOK:
if Dialog^.ListBox^.List^.Count > 0 then
if ProcessSwitch
(PProcessItem(Collection^.At(Dialog^.ListBox^.Focused))^
.Pid) <> 0
then
begin
Beep(100, 30);
goto Ret;
end;
cmButton1:
if (Dialog^.ListBox^.List^.Count > 0) and KillAllowed then
if ProcessKill
(PProcessItem(Collection^.At(Dialog^.ListBox^.Focused))^
.Pid) <> 0
then
goto Ret;
end {case};
Dispose(Dialog, Done);
Dispose(Collection, Done);
end { InsertTaskList };
begin
end.