Einzelnen Beitrag anzeigen

Benutzerbild von smepal
smepal

Registriert seit: 25. Okt 2005
Ort: Bechen
58 Beiträge
 
Delphi 2005 Personal
 
#7

Re: TPlaylist neue Komponente!

  Alt 15. Aug 2006, 19:03
@omata
meinst du sowas?
Delphi-Quellcode:
function TPlaylist.GetTracks (index: Integer): Tracks;
begin
Tracks.Title := cells[1,index];
Tracks.time := cells[2, index];
Tracks.path := cells[4, index];

end;
Der Quelltext sieht jetzt so aus:
Delphi-Quellcode:
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
 Tracks = record
  Title: String;
  time: String;
  path: String;
 end;




type
  TPlayList = class(TStringGrid)

  private
    { Private-Deklarationen }
  protected
 procedure Click; override;
 
    { Protected-Deklarationen }
  public
  public
   property Track[index:integer]:Tracks read GetTracks;
  constructor Create (AOwner: TComponent); override;
    { Public-Deklarationen }
  published
   procedure DeleteRow (RowNumber : Integer);
   procedure addFile (pfad, dauer, titel: String);
   function GetTracks(index:integer):Tracks;
   { 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;

function TPlaylist.GetTracks (index: Integer): Tracks;
begin
Tracks.Title := cells[1,index];
Tracks.time := cells[2, index];
Tracks.path := cells[4, index];

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;
Tracklist[rowcount].title := titel;
Tracklist[rowcount].time := dauer;
Tracklist[rowcount].path := pfad;

end;

procedure Tplaylist.DeleteRow(RowNumber : Integer);
var
i : Integer;
begin

Allerdings meckert er bei der
property
oben
property Track[index:integer]:Tracks read GetTracks; Feld- oder Methodenbezeichner erwartet!
Martin Krämer
Be water my friend!!!
  Mit Zitat antworten Zitat