Autor Beitrag
smepal
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68

Win XP, Linux Mandbrake,SUSE 10.1, SUSE 9 PE, DEBIAN, Win 2000 Pro, Win XP Pro
Delphi
BeitragVerfasst: Di 15.08.06 18:04 
Hallo,
ich programmiere gerade eine neu Komponente, die die Funktion einer Playlist haben soll. Als Vorlage dafür habe ich ein TStringgrid genommen, das ich nun modifiziere bzw erweitere.

Nun möchte ich, dass wenn man der Playlist einen Track hinzufügt, die Daten in Form eines Arrays oder ähnlichem nachher abrufbar sind.
(Die add-Procedur findet ihr unten)

D.h. dieser Code sollte zum Beispiel Infos von Track1 zurückgeben:
ausblenden Delphi-Quelltext
1:
2:
3:
playlist.tracks[1].path
playlist.tracks[1].name
playlist.tracks[1].time


Wie kann ich das realisieren?

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:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
unit playlist;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Grids, StdCtrls, Buttons, ExtCtrls;

type
  TInfos = class
    Filename:string;
  public
    property Str:string read Filename write Filename;
  end;

type
  TPlayList = class(TStringGrid)
  
  private
    { Private-Deklarationen }
  protected
 procedure Click; override;
 
    { Protected-Deklarationen }
  public
  constructor Create (AOwner: TComponent); override;
    { Public-Deklarationen }
  published
   procedure DeleteRow (RowNumber : Integer);
   procedure addFile (pfad, dauer, titel: String);
   { Published-Deklarationen }
  end;

procedure Register;

implementation

constructor TPlaylist.Create(AOwner: TComponent);

begin
inherited Create (AOwner);
rowcount := 2;
 colcount := 3;
 fixedcols := 0;
 fixedrows := 1;
 defaultrowheight := 15;
 rowheights[0] := 18;
Cells[0,0] := 'Title';
Cells[1,0] := 'Length';
Cells[2,0] := 'x';
ColWidths[0] := 200;
colwidths[1] := 50;
colwidths[2] := defaultrowheight;


end;

procedure TPlaylist.addFile (pfad, dauer, titel: String);
var i: Integer;
mo: TInfos;
begin
rowcount := rowcount + 1;



mo:=TInfos.create;
    mo.Filename:='';
    Objects[rowcount-1,3]:=mo;


cells[0, rowcount-1] := titel;
cells[1, rowcount-1] := dauer;
cells[2,rowcount-1] := 'x';
cells[3,rowcount-1] := pfad;


end;

procedure Tplaylist.DeleteRow(RowNumber : Integer);
var
i : Integer;
begin
  for i := RowNumber to RowCount - 2 do
    Rows[i].Assign(Rows[i+ 1]);
  Rows[RowCount-1].Clear;
  RowCount := RowCount - 1;
end;

procedure TPlaylist.Click;
begin
if (col = 0) or (col = 1) then
selection := TGridRect(Rect(0, row, colcount, row));
if (col = 2) then
   if (row <> 0) then
      deleterow(row);
end;

procedure Register;
begin
  RegisterComponents('Standard', [TPlayList]);
end;



end.