Wim,
> Please, could some-one help me in parsing a little example for a
> progress-bar with ftp-upload ? Of course, a Delphi-source, not a
> BCB-source.
I sent here an example on Tuesday 23 January 2007.
However it probably was some server problem that day and I sent to your=20
e-mail. Did you shold chek you e-mail box. This is the copy:
On Tuesday 23 January 2007 07:12, Wim Vanmaele wrote:
> I can send a file, but when it is a file of about 12 Mb it would be ver=
ry
> interesting following the progress of the transfert.
> I already looked for the examples, but I do no understand them, or wors=
er,
> I do not know exactly how, where en when. =A0I saw I had to make an
> connection to
> tftpsend1.Dsock.onstatus, but that is all I can follow.
> Can someone help me please ?
It seems there is some problem to send reply on Synapse maillist.
Anyway, this may help you to solve the problem:
There is two event hooks now: OnStatus and OnMonitor.=20
If you have to count or add sent/received data, or even get the data bloc=
k, it=20
is very useful OnMonitor.
Anyway, this is the sample code for HTTP transfer I use. Each hooks you=20
may modify by your own needs. You can use both hookds or one of it, depen=
ding=20
of what you need to accomplish.
var
=A0 SizeIn,SizeOut: integer;
type
=A0 THookSocketStatus =3D procedure(Sender: TObject; Reason: THookSocketR=
eason;
=A0 =A0 const Value: string) of object;
=A0 TMemory=3Dpointer;
=A0 =A0callback =3D class
=A0 =A0 =A0 =A0class procedure Status (Sender: TObject; Reason: THookSock=
etReason;=20
const Value: String);
=A0 =A0 =A0 =A0class procedure Monitor (Sender: TObject; Writing: Boolean=
; const=20
Buffer: TMemory; Len: Integer);
=A0 =A0 =A0end;
class procedure callback.Status(Sender: TObject; Reason: THookSocketReaso=
n;
=A0 const Value: String);
var v: String;
begin
=A0 v :=3D getEnumName (typeinfo(THookSocketReason), integer(Reason)) + '=
' +=20
Value;
=A0 Form1.Memo2.Lines.Add(v);
=A0 if (reason=3Dhr_readcount) then
=A0 =A0 =A0inc(SizeIN,StrToInt64Def(Value,0));
=A0 if (reason=3Dhr_writecount) then
=A0 =A0 =A0inc(SizeOUT,StrToInt64Def(Value,0));
=A0 Form1.lblIN.Caption :=3Dinttostr(SizeIN);
=A0 Form1.lblOUT.Caption:=3Dinttostr(SizeOUT);
=A0 application.ProcessMessages;
end;
class procedure callback.Monitor (Sender: TObject; Writing: Boolean; cons=
t=20
Buffer: TMemory; Len: Integer);
begin
=A0 if not writing then
=A0 =A0 =A0inc(SizeIN, Len)
=A0 else
=A0 =A0 =A0inc(SizeOUT, Len);
=A0 Form1.lblIN.Caption :=3Dinttostr(SizeIN);
=A0 Form1.lblOUT.Caption:=3Dinttostr(SizeOUT);
=A0 application.ProcessMessages;
end;
procedure TForm1.btnGETClick(Sender: TObject);
var
=A0 HTTP: THTTPSend;
=A0 F: TFileStream;
=A0 Start,Size: integer;
begin
=A0 SizeIN:=3D0;
=A0 SizeOUT:=3D0;
=A0 Memo2.Lines.Add(CRLF+'GET');
=A0 Memo2.Lines.Add('------------');
=A0 Size:=3DHttpGetFileSize(Edit1.text);
=A0 HTTP :=3D THTTPSend.Create;
=A0 HTTP.Sock.OnStatus :=3D callback.Status;
=A0 //or=20
=A0 HTTP.Sock.OnMonitor :=3D callback.Monitor;
=A0 ...
Sasa
--
http://www.szutils.net
|