TreeView para arquivo . INI

Delphi

04/09/2006

(Dúvida de iniciante...) Alguém já usou estas procedures, abaixo? Onde estaria sendo criado o arquivo .ini? E como gravar também no arquivo ini as imagens relacionadas aos nodes que estão no ImageList? Obrigado...
save a TTreeView to a Ini-File?

procedure TreeToIni(Tree: TTreeView; INI: TIniFile; Section: string);
var
n: Integer;
MS: TMemoryStream;
tTv: TStringList;
Msg: string;
begin
tTv := TStringList.Create;
MS := TMemoryStream.Create;
try
Tree.SaveToStream(MS);
MS.Position := 0;
tTv.LoadFromStream(MS);
INI.EraseSection(Section);
for n := 0 to tTv.Count - 1 do
INI.WriteString(Section, ´Node´ + IntToStr(n), StringReplace(tTv[n], #9,
´´, [rfReplaceAll]));
finally
tTv.Free;
MS.Free;
end;
end;

procedure TreeFromIni(Tree: TTreeView; INI: TIniFile; Section: string;
Expand: Boolean);
var
n: Integer;
MS: TMemoryStream;
tTv: TStringList;
Msg: string;
begin
tTv := TStringList.Create;
MS := TMemoryStream.Create;
try
INI.ReadSection(Section, tTv);
for n := 0 to tTv.Count - 1 do
tTv[n] := StringReplace(INI.ReadString(Section, tTv[n], ´´), ´#´, 9,
[rfReplaceAll]);
tTv.SaveToStream(MS);
MS.Position := 0;
Tree.LoadFromStream(MS);
if (Expand = True) and (Tree.Items.Count > 0) then
Tree.Items[0].Expand(True);
finally
tTv.Free;
MS.Free;
end;
end;


Scienter8

Scienter8

Curtidas 0
POSTAR