Hi superior,
ungetesteter Code:
Delphi-Quellcode:
type
TListViewFileItem = record
Caption: String[255];
NumSubItems: Integer;
SubItems: array[0..99] of String[255];
end;
TListViewFile = file of TListViewFileItem;
procedure LoadListViewFromFile(ListView: TListView; FileName: String);
var
i, j: Integer;
FileVar: TListViewFile;
ThisItem: TListViewFileItem;
NewItem: TListItem;
begin
AssignFile(FileVar, Filename);
Reset(FileVar);
ListView.Clear;
for i := 0 to FileSize(FileVar)-1 do
begin
Seek(FileVar, i);
Read(FileVar, ThisItem);
NewItem := ListView.Items.Add;
NewItem.Caption := ThisItem.Caption;
for j := 0 to ThisItem.NumSubItems-1 do
NewItem.SubItems.Add(ThisItem.SubItems[j]);
end;
CloseFile(FileVar);
end;
procedure SaveListViewToFile(ListView: TListView; FileName: String);
var
i, j: Integer;
FileVar: TListViewFile;
ThisItem: TListViewFileItem;
begin
AssignFile(FileVar, FileName);
Rewrite(FileVar);
for i := 0 to ListView.Items.Count-1 do
begin
with ListView.Items[i] do
begin
ThisItem.Caption := Caption;
ThisItem.NumSubItems := SubItems.Count;
for j := 0 to SubItems.Count-1 do
ThisItem.SubItems[i] := SubItems[i];
end;
Seek(FileVar, i);
Write(FileVar, ThisItem);
end;
CloseFile(FileVar);
end;
Die Funktionen sollten sich eigentlich selbst erklären. Lass mich bitte wissen ob sie funktionieren, ich hab keine Zeit
und keine Lust zum Testen.
Greetz
alcaeus