| 1 |
unit ULinkerList; |
|---|
| 2 |
|
|---|
| 3 |
interface |
|---|
| 4 |
|
|---|
| 5 |
uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls, |
|---|
| 6 |
Buttons, ExtCtrls; |
|---|
| 7 |
|
|---|
| 8 |
type |
|---|
| 9 |
TLinkerListDlg = class(TForm) |
|---|
| 10 |
OKBtn: TButton; |
|---|
| 11 |
CancelBtn: TButton; |
|---|
| 12 |
GroupBox1: TGroupBox; |
|---|
| 13 |
linkerListbox: TListBox; |
|---|
| 14 |
addEdit: TEdit; |
|---|
| 15 |
AddButton: TButton; |
|---|
| 16 |
DeleteButton: TButton; |
|---|
| 17 |
procedure AddButtonClick(Sender: TObject); |
|---|
| 18 |
procedure DeleteButtonClick(Sender: TObject); |
|---|
| 19 |
private |
|---|
| 20 |
{ Private declarations } |
|---|
| 21 |
public |
|---|
| 22 |
{ Public declarations } |
|---|
| 23 |
|
|---|
| 24 |
{ Edit a list of flags, returns true if they were modified } |
|---|
| 25 |
function EditList( list : TStringList ): boolean; |
|---|
| 26 |
end; |
|---|
| 27 |
|
|---|
| 28 |
var |
|---|
| 29 |
LinkerListDlg: TLinkerListDlg; |
|---|
| 30 |
|
|---|
| 31 |
implementation |
|---|
| 32 |
|
|---|
| 33 |
{$R *.DFM} |
|---|
| 34 |
|
|---|
| 35 |
function TLinkerListDlg.EditList( list:TStringList ) : boolean; |
|---|
| 36 |
var |
|---|
| 37 |
r : Integer; |
|---|
| 38 |
begin |
|---|
| 39 |
Self.linkerListbox.Items.Clear; |
|---|
| 40 |
Self.linkerListbox.Items.AddStrings( list ); |
|---|
| 41 |
Self.DeleteButton.Enabled := list.Count > 0; |
|---|
| 42 |
Self.addEdit.Text := ''; |
|---|
| 43 |
r := Self.ShowModal; |
|---|
| 44 |
Result := false; |
|---|
| 45 |
if r <> mrOk then Exit; |
|---|
| 46 |
list.Clear; |
|---|
| 47 |
list.AddStrings( linkerListbox.Items ); |
|---|
| 48 |
result:= true; |
|---|
| 49 |
end; |
|---|
| 50 |
|
|---|
| 51 |
procedure TLinkerListDlg.AddButtonClick(Sender: TObject); |
|---|
| 52 |
var |
|---|
| 53 |
str : string; |
|---|
| 54 |
begin |
|---|
| 55 |
str := Trim( addEdit.Text ); |
|---|
| 56 |
if Length( str ) < 1 then Exit; |
|---|
| 57 |
if linkerListbox.Items.IndexOf( str ) >-1 then Exit; |
|---|
| 58 |
linkerListBox.Items.Add( str ); |
|---|
| 59 |
addEdit.Text := ''; |
|---|
| 60 |
Self.DeleteButton.Enabled := LinkerListbox.items.count > 0; |
|---|
| 61 |
end; |
|---|
| 62 |
|
|---|
| 63 |
procedure TLinkerListDlg.DeleteButtonClick(Sender: TObject); |
|---|
| 64 |
var |
|---|
| 65 |
N : Integer; |
|---|
| 66 |
SL : TStringList; |
|---|
| 67 |
begin |
|---|
| 68 |
if linkerListbox.SelCount < 1 then Exit; |
|---|
| 69 |
SL := TStringList.Create; |
|---|
| 70 |
with( linkerListbox ) do |
|---|
| 71 |
for N:=0 to Items.Count-1 do begin |
|---|
| 72 |
if Selected[ N ]=false then SL.Add( Items[N] ); |
|---|
| 73 |
end; |
|---|
| 74 |
linkerListbox.Clear; |
|---|
| 75 |
if SL.Count > 0 then linkerListbox.Items.AddStrings( SL ) |
|---|
| 76 |
else DeleteButton.Enabled:= false; |
|---|
| 77 |
SL.Free; |
|---|
| 78 |
Self.DeleteButton.Enabled := LinkerListbox.items.count > 0; |
|---|
| 79 |
end; |
|---|
| 80 |
|
|---|
| 81 |
end. |
|---|