AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Virtual TreeView mit INI füllen

Ein Thema von EWeiss · begonnen am 1. Sep 2008 · letzter Beitrag vom 12. Sep 2008
Antwort Antwort
EWeiss
(Gast)

n/a Beiträge
 
#1

Re: Virtual TreeView mit INI füllen

  Alt 2. Sep 2008, 00:40
Zitat von omata:
Hier mal ein kleines Beispiel...
Das ist nett von dir ..
Danke schön

Dann nochmal auch für andere ...

Normales TreeView
Delphi-Quellcode:
procedure TMainForm.ParseIniToTree(INIFileName: string; TreeView: TTreeView);

  function IdOf(s: string): string;
  begin
    result := s;
  end;

  function ValOf(s: string): string;
  begin
    result := copy(s, pos('=', s) + 1, maxint);
  end;

var INI : TIniFile; // Ini File
    Section : TStringList; // Section
    Value : TStringList; // Ergebnis
    node : TTreeNode; // Node
    IntSect : integer; // Zähler für Section
    IntValue : integer; // Zähler für Ergebnis

begin
  if (not FileExists(INIFileName)) then
    exit;

  INI := TIniFile.Create(INIFileName);
  Section := TStringList.Create;
  Value := TStringList.Create;

  try

    INI.ReadSections(Section);
    for IntSect := 0 to Section.Count - 1 do
    begin
      node := TreeView.Items.AddChild(nil, Section[IntSect]);
      INI.ReadSectionValues(Section[IntSect], Value);
      for IntValue := 0 to Value.Count - 1 do
        TreeView.Items.AddChildObject(node,
                                IdOf(Value[IntValue]),
                                pointer(StrToIntDef(ValOf(Value[IntValue]),
                                0)));
    end;

  finally
    INI.Free;
    Section.Free;
    Value.Free;
  end;

end;
und für VirtualTreeView
Delphi-Quellcode:
procedure TFMain.ParseIniToTree(INIFileName: string; TreeView: TVirtualStringTree);

  function IdOf(s: string): string;
  begin
    result := s;
  end;

  function ValOf(s: string): string;
  begin
    result := copy(s, pos('=', s) + 1, maxint);
  end;

var INI : TIniFile; // Ini File
    Section : TStringList; // Section
    Value : TStringList; // Ergebnis
    Node, Parent : PVirtualNode; // Node
    IntSect : integer; // Zähler für Section
    IntValue : integer; // Zähler für Ergebnis
    Data : PTreeData;

begin
  if FileExists(INIFileName) then begin
    TreeView.Clear;
    INI := TIniFile.Create(INIFileName);
    Section := TStringList.Create;
    Value := TStringList.Create;
    try
      INI.ReadSections(Section);
      for IntSect := 0 to Section.Count - 1 do
      begin
        Parent := TreeView.AddChild(nil);
        Data := TreeView.GetNodeData(Parent);
        Data^.Caption:=Section[IntSect];
        INI.ReadSectionValues(Section[IntSect], Value);
        for IntValue := 0 to Value.Count - 1 do begin
          Node:=TreeView.AddChild(Parent);
          Data := TreeView.GetNodeData(Node);
          Data^.Caption:=IdOf(Value[IntValue]);
          Data^.ValOf:=ValOf(Value[IntValue]);
        end;
      end;
    finally
      INI.Free;
      Section.Free;
      Value.Free;
    end;
  end;
end;
das wird auch anderen helfen denke ich mal
Muss jetzt nur noch schaun wie das mit Headern funktioniert dann ist es fertig
Denke hab da was auf der Seite gelesen was aber nicht funktioniert.

gruss Emil
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:33 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz