source: trunk/Forms/FormCategorySelect.pas

Last change on this file was 227, checked in by chronos, 44 hours ago
  • Modified: Do not reference global Core object if possible.
File size: 1.6 KB
Line 
1unit FormCategorySelect;
2
3interface
4
5uses
6 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
7 Acronym, FormEx;
8
9type
10
11 { TFormCategorySelect }
12
13 TFormCategorySelect = class(TFormEx)
14 ButtonOk: TButton;
15 ButtonCancel: TButton;
16 ListBox1: TListBox;
17 procedure ListBox1DblClick(Sender: TObject);
18 procedure ListBox1KeyPress(Sender: TObject; var Key: char);
19 public
20 AcronymDb: TAcronymDb;
21 procedure Load(RemoveItems: TStrings);
22 end;
23
24resourcestring
25 SCategory = 'Category';
26 SRemoveCategory = 'Remove categories';
27 SRemoveCategoryQuery = 'Do you really want to remove selected categories?';
28
29
30implementation
31
32{$R *.lfm}
33
34{ TFormCategorySelect }
35
36procedure TFormCategorySelect.ListBox1DblClick(Sender: TObject);
37begin
38 ButtonOk.Click;
39end;
40
41procedure TFormCategorySelect.ListBox1KeyPress(Sender: TObject; var Key: char);
42begin
43 if Key = #13 then ButtonOk.Click;
44end;
45
46procedure TFormCategorySelect.Load(RemoveItems: TStrings);
47var
48 Index: Integer;
49 I: Integer;
50begin
51 with AcronymDb do begin
52 ListBox1.Sorted := False;
53 while ListBox1.Items.Count < Categories.Count do
54 ListBox1.Items.Add('');
55 while ListBox1.Items.Count > Categories.Count do
56 ListBox1.Items.Delete(ListBox1.Items.Count - 1);
57 for I := 0 to Categories.Count - 1 do begin
58 ListBox1.Items.Strings[I] := Categories[I].Name;
59 ListBox1.Items.Objects[I] := Categories[I];
60 ListBox1.Selected[I] := False;
61 end;
62 ListBox1.Sorted := True;
63 for I := 0 to RemoveItems.Count - 1 do begin
64 Index := ListBox1.Items.IndexOf(RemoveItems[I]);
65 if Index <> -1 then ListBox1.Items.Delete(Index);
66 end;
67 end;
68end;
69
70end.
71
Note: See TracBrowser for help on using the repository browser.