Download wie mit delphi?

Für Fragen zur Programmiersprache auf welcher Lazarus aufbaut
Antworten
Warfley
Beiträge: 12
Registriert: So 8. Mai 2011, 09:21

Download wie mit delphi?

Beitrag von Warfley »

Hallo ich habe eine kleine frage:
Ich habe hier einen code, funtkioniert in Delphi problemlos:

Code: Alles auswählen

uses ..., ExtActns;
 
type
  TForm1 = class(TForm)
    ProgressBar1: TProgressBar;
    procedure FormCreate(Sender: TObject);
  private
         procedure URL_OnDownloadProgress
        (Sender: TDownLoadURL;
         Progress, ProgressMax: Cardinal;
         StatusCode: TURLDownloadStatus;
         StatusText: String; var Cancel: Boolean) ;
  public
    { Public declarations }
  end;
 
...
 
 
procedure TForm1.URL_OnDownloadProgress;
begin
   ProgressBar1.Max:= ProgressMax;
   ProgressBar1.Position:= Progress;
end;
 
...
 
 
Procedure TForm1.FormCreate(sender: TObject);
begin
   with TDownloadURL.Create(self) do
   try
     URL:='http://example.com/datei';
     FileName := 'c:\SpeicherPfad';
     OnDownloadProgress := self.URL_OnDownloadProgress;
     ExecuteTarget(nil) ;
   finally
     Free;
   end;
end;
Doch lazarus finded Das Uses von ExtActns nicht, gibt es da eine andere möglichkeit?

creed steiger
Beiträge: 958
Registriert: Mo 11. Sep 2006, 22:56

Re: Download wie mit delphi?

Beitrag von creed steiger »

http://www.ararat.cz/synapse/doku.php/p ... tpdownload" onclick="window.open(this.href);return false;
http://synapse.ararat.cz/doc/help/https ... pGetBinary" onclick="window.open(this.href);return false;

synapse wäre eine Möglichkeit

http://curlpas.sourceforge.net/demo/testsave.pas.html" onclick="window.open(this.href);return false;

oder curlpas

MAC
Beiträge: 770
Registriert: Sa 21. Feb 2009, 13:46
OS, Lazarus, FPC: Windows 7 (L 1.3 Built 43666 FPC 2.6.2)
CPU-Target: 32Bit

Re: Download wie mit delphi?

Beitrag von MAC »

Hallo.
Mal ganz davon abgesehen das bei Lazarus in der folgenden Zeile ein @ hinkommt (Damit der Compiler weis das ein Pointer auf die Funktion übergeben werden soll und nicht die funktion aufgerufen wird...)

Code: Alles auswählen

OnDownloadProgress := @self.URL_OnDownloadProgress;
Eigentlich wollte ich hier lNet vorschlagen. Aber ich sehe ich habe ein recht einfaches beispiel bei mir rumliegen:
Das benutzt auch synapse bzw. die unit httpsend. (synapse muss man nicht installieren - einfach nur eine unitsammlung)

Code: Alles auswählen

var
  URL:string;
begin   
URL := Edit1.Text;
if HttpGetText(URL,Memo1.Lines) then Form1.Caption:='Alles OK';
   else Form1.Caption:='Fehler';         
end;
In Edit1 Steht dann z,B
http://www.lazarusforum.de/viewtopic.php?f=10&t=5011" onclick="window.open(this.href);return false;

und dann sollte Diese Seite in der Memo angezeigt werden...

Code: Alles auswählen

Signatur := nil;

marcov
Beiträge: 1103
Registriert: Di 5. Aug 2008, 09:37
OS, Lazarus, FPC: Windows ,Linux,FreeBSD,Dos (L trunk FPC trunk)
CPU-Target: 32/64,PPC(+64), ARM
Wohnort: Eindhoven (Niederlande)

Re: Download wie mit delphi?

Beitrag von marcov »

Auf Windows kann man glaub ich auch Unit Wininet nutzen. Das hat der Vorteil das es automatisch MSIE proxy Einstellungen uebernimmt.

Zb:

http://www.cryer.co.uk/brian/delphi/win ... e_http.htm" onclick="window.open(this.href);return false;

Antworten