source: tags/1.4.0/Forms/UFormCategorySelect.pas

Last change on this file was 96, checked in by chronos, 8 years ago
  • Fixed: Dynamically created forms were not translated.
File size: 2.0 KB
Line 
1unit UFormCategorySelect;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
9 UAcronym;
10
11type
12
13 { TFormCategorySelect }
14
15 TFormCategorySelect = class(TForm)
16 ButtonOk: TButton;
17 ButtonCancel: TButton;
18 ListBox1: TListBox;
19 procedure FormCreate(Sender: TObject);
20 procedure FormShow(Sender: TObject);
21 procedure ListBox1DblClick(Sender: TObject);
22 procedure ListBox1KeyPress(Sender: TObject; var Key: char);
23 private
24 { private declarations }
25 public
26 procedure Load(RemoveItems: TStrings);
27 end;
28
29var
30 FormCategorySelect: TFormCategorySelect;
31
32resourcestring
33 SCategory = 'Category';
34 SRemoveCategory = 'Remove categories';
35 SRemoveCategoryQuery = 'Do you really want to remove selected categories?';
36
37implementation
38
39{$R *.lfm}
40
41uses
42 UCore;
43
44{ TFormCategorySelect }
45
46procedure TFormCategorySelect.FormShow(Sender: TObject);
47begin
48end;
49
50procedure TFormCategorySelect.FormCreate(Sender: TObject);
51begin
52 Core.CoolTranslator1.TranslateComponentRecursive(Self);
53end;
54
55procedure TFormCategorySelect.ListBox1DblClick(Sender: TObject);
56begin
57 ButtonOk.Click;
58end;
59
60procedure TFormCategorySelect.ListBox1KeyPress(Sender: TObject; var Key: char);
61begin
62 if Key = #13 then ButtonOk.Click;
63end;
64
65procedure TFormCategorySelect.Load(RemoveItems: TStrings);
66var
67 Index: Integer;
68 I: Integer;
69begin
70 with Core.AcronymDb do begin
71 ListBox1.Sorted := False;
72 while ListBox1.Items.Count < Categories.Count do
73 ListBox1.Items.Add('');
74 while ListBox1.Items.Count > Categories.Count do
75 ListBox1.Items.Delete(ListBox1.Items.Count - 1);
76 for I := 0 to Categories.Count - 1 do begin
77 ListBox1.Items.Strings[I] := TAcronymCategory(Categories[I]).Name;
78 ListBox1.Items.Objects[I] := Categories[I];
79 ListBox1.Selected[I] := False;
80 end;
81 ListBox1.Sorted := True;
82 for I := 0 to RemoveItems.Count - 1 do begin
83 Index := ListBox1.Items.IndexOf(RemoveItems[I]);
84 if Index <> -1 then ListBox1.Items.Delete(Index);
85 end;
86 end;
87end;
88
89end.
90
Note: See TracBrowser for help on using the repository browser.