type
TDownloadFortschritt =
procedure (Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer)
of object;
TForm1 =
class(TForm)
private
MeineKomponente: TMeineKomponente;
procedure StarteDownload;
procedure MeineKomponenteDownloadFortschritt(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
end;
TMeineKomponente =
class (TComponent)
{ private deklarationen }
private
FIdHTTP: TIdHTTP;
FOnDownloadFortschritt : TDownloadFortschritt;
// du hattest TOnDownloadFortschritt
procedure IdHTTPWork(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
public
constructor Create;
property OnDownloadFortschritt: TDownloadFortschritt
read FOnDownloadFortschritt
write FOnDownloadFortschritt ;
end;
var
Form1: TForm1;
implementation
procedure Form1.StarteDownload;
begin
// Komponente fertig machen und sowas...
MeineKomponente.OnDownloadFortschritt = MeineKomponenteDownloadFortschritt;
MeineKomponente.Execute;
end;
procedure Form1.MeineKomponenteDownloadFortschritt(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
begin
// Hier haste alles in deiner Form jetzt ;-)
end;
procedure TMeineKomponente.Execute;
begin
FIdHTTP.OnWork := IdHTTPWork;
FIdHTTP.Get(
url, fs);
// fs ist'n filestream
end;
procedure TMeineKomponente.IdHTTPWork(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
begin
if Assigned(FOnDownloadFortschritt)
then
FOnDownloadFortschritt(NamenKenneIchNicht);
end;