Ignore:
Timestamp:
Sep 10, 2022, 6:54:43 PM (2 years ago)
Author:
chronos
Message:
  • Modified: CoolTranslator replaced by Common package.
  • Modified: Update common package.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/ULastOpenedList.pas

    r10 r25  
    11unit ULastOpenedList;
    2 
    3 {$mode delphi}
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, Registry, URegistry, Menus, XMLConf;
     6  Classes, SysUtils, Registry, URegistry, Menus, XMLConf, DOM;
    97
    108type
     
    3028    procedure SaveToXMLConfig(XMLConfig: TXMLConfig; Path: string);
    3129    procedure AddItem(FileName: string);
     30    function GetFirstFileName: string;
    3231  published
    3332    property MaxCount: Integer read FMaxCount write SetMaxCount;
     
    8382destructor TLastOpenedList.Destroy;
    8483begin
    85   Items.Free;
     84  FreeAndNil(Items);
    8685  inherited;
    8786end;
     
    9392begin
    9493  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;
    96100    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;
    101103    end;
    102104  end;
     
    139141    OpenKey(Context.Key, True);
    140142    for I := 0 to Items.Count - 1 do
    141       WriteString('File' + IntToStr(I), UTF8Decode(Items[I]));
     143      WriteString('File' + IntToStr(I), Items[I]);
    142144  finally
    143145    Free;
     
    153155begin
    154156  with XMLConfig do begin
    155     Count := GetValue(Path + '/Count', 0);
     157    Count := GetValue(DOMString(Path + '/Count'), 0);
    156158    if Count > MaxCount then Count := MaxCount;
    157159    Items.Clear;
    158160    for I := 0 to Count - 1 do begin
    159       Value := GetValue(Path + '/File' + IntToStr(I), '');
     161      Value := string(GetValue(DOMString(Path + '/File' + IntToStr(I)), ''));
    160162      if Trim(Value) <> '' then Items.Add(Value);
    161163    end;
     
    170172begin
    171173  with XMLConfig do begin
    172     SetValue(Path + '/Count', Items.Count);
     174    SetValue(DOMString(Path + '/Count'), Items.Count);
    173175    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]));
    175177    Flush;
    176178  end;
     
    185187end;
    186188
     189function TLastOpenedList.GetFirstFileName: string;
     190begin
     191  if Items.Count > 0 then Result := Items[0]
     192    else Result := '';
     193end;
     194
    187195end.
    188196
Note: See TracChangeset for help on using the changeset viewer.