Autor Beitrag
FriFra
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: Sa 01.05.04 10:04 
Mit den folgenden beiden Funktionen kann man die Nodes eines TreeView in eine ini speichern, bzw. aus einer ini lesen.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
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 > 0then
    begin
      Tree.Items[0].Expand(True);
      Tree.Items[0].MakeVisible;
    end;
  finally 
    tTv.Free; 
    MS.Free; 
  end
end;

_________________
Michael
(principal certified lotus professional - developer)