J
Jaspers
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, UrlMon, StdCtrls, cxControls, cxContainer, cxEdit, cxTextEdit,
cxMaskEdit, cxButtonEdit, ComCtrls, ExtActns;
type
TForm1 = class(TForm)
edtRemote: TEdit;
Label1: TLabel;
Label2: TLabel;
edtLocal2: TcxButtonEdit;
ProgressBar1: TProgressBar;
Button2: TButton;
Edit1: TEdit;
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TDownloadThread = class(TThread)
private
FProgBar: TProgressBar;
FRemote: string;
FLocal: string;
proceduredo
wnLoadFile;
proceduredo
OnDownLoadProgress(Sender: TDownLoadURL;
Progress, ProgressMax:Cardinal;
StatusCode: TURLDownloadStatus;
StatusText: String;
var Cancel: Boolean);
protected
constructor Create(ABar: TProgressBar;ARemote, ALocal: string);
procedure Execute;
override;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TDownloadThread }
constructor TDownloadThread.Create(ABar: TProgressBar;ARemote, ALocal: string);
begin
FProgBar := ABar;
FRemote := ARemote;
FLocal := ALocal;
inherited Create(true);
end;
procedure TDownloadThread.DoOnDownLoadProgress(Sender: TDownLoadURL;
Progress, ProgressMax: Cardinal;
StatusCode: TURLDownloadStatus;
StatusText: String;
var Cancel: Boolean);
begin
FProgBar.Position := Progress;
FProgBar.Max := ProgressMax;
end;
procedure TDownloadThread.DownLoadFile;
begin
with TDownloadURL.Create(nil)do
try
URL := FRemote;
FileName := FLocal;
OnDownloadProgress :=do
OnDownLoadProgress;
ExecuteTarget(nil);
finally
Free;
end;
end;
procedure TDownloadThread.Execute;
begin
inherited;
Synchronize(DownloadFile);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
thrd: TDownloadThread;
begin
thrd := TDownloadThread.Create(ProgressBar1, edtRemote.Text, edtLocal.Text);
thrd.Resume;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, UrlMon, StdCtrls, cxControls, cxContainer, cxEdit, cxTextEdit,
cxMaskEdit, cxButtonEdit, ComCtrls, ExtActns;
type
TForm1 = class(TForm)
edtRemote: TEdit;
Label1: TLabel;
Label2: TLabel;
edtLocal2: TcxButtonEdit;
ProgressBar1: TProgressBar;
Button2: TButton;
Edit1: TEdit;
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TDownloadThread = class(TThread)
private
FProgBar: TProgressBar;
FRemote: string;
FLocal: string;
proceduredo
wnLoadFile;
proceduredo
OnDownLoadProgress(Sender: TDownLoadURL;
Progress, ProgressMax:Cardinal;
StatusCode: TURLDownloadStatus;
StatusText: String;
var Cancel: Boolean);
protected
constructor Create(ABar: TProgressBar;ARemote, ALocal: string);
procedure Execute;
override;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TDownloadThread }
constructor TDownloadThread.Create(ABar: TProgressBar;ARemote, ALocal: string);
begin
FProgBar := ABar;
FRemote := ARemote;
FLocal := ALocal;
inherited Create(true);
end;
procedure TDownloadThread.DoOnDownLoadProgress(Sender: TDownLoadURL;
Progress, ProgressMax: Cardinal;
StatusCode: TURLDownloadStatus;
StatusText: String;
var Cancel: Boolean);
begin
FProgBar.Position := Progress;
FProgBar.Max := ProgressMax;
end;
procedure TDownloadThread.DownLoadFile;
begin
with TDownloadURL.Create(nil)do
try
URL := FRemote;
FileName := FLocal;
OnDownloadProgress :=do
OnDownLoadProgress;
ExecuteTarget(nil);
finally
Free;
end;
end;
procedure TDownloadThread.Execute;
begin
inherited;
Synchronize(DownloadFile);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
thrd: TDownloadThread;
begin
thrd := TDownloadThread.Create(ProgressBar1, edtRemote.Text, edtLocal.Text);
thrd.Resume;
end;
end.