Changeset 25 for trunk/Packages/Common/ULastOpenedList.pas
- Timestamp:
- Sep 10, 2022, 6:54:43 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/ULastOpenedList.pas
r10 r25 1 1 unit ULastOpenedList; 2 3 {$mode delphi}4 2 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, Registry, URegistry, Menus, XMLConf ;6 Classes, SysUtils, Registry, URegistry, Menus, XMLConf, DOM; 9 7 10 8 type … … 30 28 procedure SaveToXMLConfig(XMLConfig: TXMLConfig; Path: string); 31 29 procedure AddItem(FileName: string); 30 function GetFirstFileName: string; 32 31 published 33 32 property MaxCount: Integer read FMaxCount write SetMaxCount; … … 83 82 destructor TLastOpenedList.Destroy; 84 83 begin 85 Items.Free;84 FreeAndNil(Items); 86 85 inherited; 87 86 end; … … 93 92 begin 94 93 if Assigned(MenuItem) then begin 95 MenuItem.Clear; 94 while MenuItem.Count > Items.Count do 95 MenuItem.Delete(MenuItem.Count - 1); 96 while MenuItem.Count < Items.Count do begin 97 NewMenuItem := TMenuItem.Create(MenuItem); 98 MenuItem.Add(NewMenuItem); 99 end; 96 100 for I := 0 to Items.Count - 1 do begin 97 NewMenuItem := TMenuItem.Create(MenuItem); 98 NewMenuItem.Caption := Items[I]; 99 NewMenuItem.OnClick := ClickAction; 100 MenuItem.Add(NewMenuItem); 101 MenuItem.Items[I].Caption := Items[I]; 102 MenuItem.Items[I].OnClick := ClickAction; 101 103 end; 102 104 end; … … 139 141 OpenKey(Context.Key, True); 140 142 for I := 0 to Items.Count - 1 do 141 WriteString('File' + IntToStr(I), UTF8Decode(Items[I]));143 WriteString('File' + IntToStr(I), Items[I]); 142 144 finally 143 145 Free; … … 153 155 begin 154 156 with XMLConfig do begin 155 Count := GetValue( Path + '/Count', 0);157 Count := GetValue(DOMString(Path + '/Count'), 0); 156 158 if Count > MaxCount then Count := MaxCount; 157 159 Items.Clear; 158 160 for I := 0 to Count - 1 do begin 159 Value := GetValue(Path + '/File' + IntToStr(I), '');161 Value := string(GetValue(DOMString(Path + '/File' + IntToStr(I)), '')); 160 162 if Trim(Value) <> '' then Items.Add(Value); 161 163 end; … … 170 172 begin 171 173 with XMLConfig do begin 172 SetValue( Path + '/Count', Items.Count);174 SetValue(DOMString(Path + '/Count'), Items.Count); 173 175 for I := 0 to Items.Count - 1 do 174 SetValue( Path + '/File' + IntToStr(I), Items[I]);176 SetValue(DOMString(Path + '/File' + IntToStr(I)), DOMString(Items[I])); 175 177 Flush; 176 178 end; … … 185 187 end; 186 188 189 function TLastOpenedList.GetFirstFileName: string; 190 begin 191 if Items.Count > 0 then Result := Items[0] 192 else Result := ''; 193 end; 194 187 195 end. 188 196
Note:
See TracChangeset
for help on using the changeset viewer.