Autor Beitrag
Regan
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: So 28.01.07 15:40 
Hallo,
wie sachaffe ich es, dass die Kompo einen Titel angibt und Elemente annimmt. (Wie bei Nemp)

MfG
Regan
Robinator
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 275

WinXP
BDS 2006
BeitragVerfasst: So 28.01.07 15:42 
In der Hilfe zur VirutalStringTree sind ein paar hervorragende beispiele ;)

Einfach mal reingucken.

Gruss, Rob
Regan Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: So 28.01.07 15:50 
OK Danke.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 28.01.07 15:55 
Der VST ist recht komplex, was seine Handhabung angeht, dafür kann er aber auch sehr viel.

Am Anfang steht der Datentyp, der in den VST rein soll. Das kann z.B. so aussehen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
type TTreeData = record
  FAudioFile : TAudioFile;
end;
type PTreeData = ^TTreeData;
Was TAudiofile ist? Nunja - das ist die Klasse, die die Audiodaten speichert.

Dann müssen wir erklären, wie ein Knoten in den Baum reinkommt. In den Beispielen findet man so etwas:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
function AddVSTMp3(AVST: TCustomVirtualStringTree; aNode: PVirtualNode; aAudioFile: TAudioFile): PVirtualNode;
var Data: PTreeData;
begin
  Result := AVST.AddChild(aNode); // meistens wohl Nil
  AVST.ValidateNode(Result,false); 
  Data := AVST.GetNodeData(Result);
  Data^.FAudioFile := aAudioFile;
end;


Bei Nemp liegen alle Daten in Objectlists vor. Den Tree befülle ich dann so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TTntForm1.FillTreeView(aVST: TVirtualStringTree; MP3Liste: TObjectlist);
var i: integer;
begin
  aVST.BeginUpdate;
  for i := 0 to MP3Liste.Count-1 do
    AddVSTMp3(aVST,Nil,TAudioFile(MP3Liste.Items[i]));
  aVST.EndUpdate;
end;


Und dann müssen wir dem Baum noch erklären, was er schreiben soll. Dafür gibts das Event OnGetText. Für die Playlist sieht das bei mir zur Zeit (gekürzt) so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure TTntForm1.PlaylistVSTGetText(Sender: TBaseVirtualTree;
  Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
  var CellText: WideString);
var Data: PTreeData;
begin
  // Daten des Knotens bestimmen
  Data := Sender.GetNodeData(Node);
  // anzeigen. 1. Spalte Titel, zweite Dauer
  case Column of
    0: begin
          CellText := Data^.FAudioFile.Artist + ' - ' + Data^.FAudioFile.Titel;
       end;
    1:  begin
          CellText := SekIntToMinStr(Data^.FAudioFile.Dauer);         
        end;
  end;
end;

_________________
We are, we were and will not be.