Changeset 13 for trunk/UFormAcronym.pas
- Timestamp:
- Apr 28, 2016, 10:09:02 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UFormAcronym.pas
r8 r13 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus, 9 StdCtrls, UAcronym;9 StdCtrls, ActnList, UAcronym; 10 10 11 11 type … … 14 14 15 15 TFormAcronym = class(TForm) 16 ACategoryRemove: TAction; 17 ACategoryAdd: TAction; 18 ActionList1: TActionList; 19 Button1: TButton; 20 Button2: TButton; 16 21 ButtonOk: TButton; 17 22 ButtonCancel: TButton; … … 21 26 Label2: TLabel; 22 27 Label3: TLabel; 28 Label4: TLabel; 29 ListBox1: TListBox; 23 30 MemoDescription: TMemo; 31 PopupMenuCategory: TPopupMenu; 32 procedure ACategoryAddExecute(Sender: TObject); 33 procedure ACategoryRemoveExecute(Sender: TObject); 24 34 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 25 35 procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); 26 36 procedure FormShow(Sender: TObject); 37 procedure ListBox1SelectionChange(Sender: TObject; User: boolean); 27 38 private 28 { private declarations }39 procedure UpdateInterface; 29 40 public 30 41 procedure Load(Entry: TAcronymEntry); … … 40 51 41 52 uses 42 UFormMain; 53 UFormMain, UFormCategorySelect; 54 55 resourcestring 56 SCategory = 'Category'; 57 SRemoveCategory = 'Remove categories'; 58 SRemoveCategoryQuery = 'Do you really want to remove selected categories?'; 43 59 44 60 { TFormAcronym } … … 57 73 end; 58 74 75 procedure TFormAcronym.ACategoryAddExecute(Sender: TObject); 76 var 77 I: Integer; 78 begin 79 FormCategorySelect.Load(ListBox1.Items); 80 if FormCategorySelect.ShowModal = mrOk then begin 81 for I := 0 to FormCategorySelect.ListBox1.Count - 1 do 82 if FormCategorySelect.ListBox1.Selected[I] then begin 83 ListBox1.Items.AddObject(FormCategorySelect.ListBox1.Items[I], FormCategorySelect.ListBox1.Items.Objects[I]); 84 end; 85 end; 86 end; 87 88 procedure TFormAcronym.ACategoryRemoveExecute(Sender: TObject); 89 var 90 I: Integer; 91 begin 92 if MessageDlg(SRemoveCategory, SRemoveCategoryQuery, 93 TMsgDlgType.mtConfirmation, [mbCancel, mbOk], 0) = mrOk then begin 94 for I := ListBox1.Items.Count - 1 downto 0 do 95 if ListBox1.Selected[I] then 96 ListBox1.Items.Delete(I); 97 UpdateInterface; 98 end; 99 end; 100 59 101 procedure TFormAcronym.FormShow(Sender: TObject); 60 102 begin 61 103 FormMain.PersistentForm1.Load(Self); 104 UpdateInterface; 105 end; 106 107 procedure TFormAcronym.ListBox1SelectionChange(Sender: TObject; User: boolean); 108 begin 109 UpdateInterface; 110 end; 111 112 procedure TFormAcronym.UpdateInterface; 113 begin 114 ACategoryRemove.Enabled := ListBox1.ItemIndex <> -1; 62 115 end; 63 116 … … 67 120 EditMeaning.Text := Entry.Meaning; 68 121 MemoDescription.Text := Entry.Description; 122 ListBox1.Items.Assign(Entry.Categories); 69 123 end; 70 124 … … 74 128 Entry.Meaning := EditMeaning.Text; 75 129 Entry.Description := MemoDescription.Text; 130 Entry.Categories.Assign(ListBox1.Items); 76 131 end; 77 132
Note:
See TracChangeset
for help on using the changeset viewer.