This is an old revision of the document!


ProgressBar for ftp data (send/receive)

Here is some example code for read/ write data:

// CallBack function, add more THookSocketReason events
 
procedure TftpForm.SockPutCallBack(Sender: TObject;
  Reason: THookSocketReason; const Value: string);
begin
  case Reason of
    HR_WriteCount: // HR_ReadCount // Value contains number of bytes
      begin
        inc(CurrentBytes, StrToIntDef(Value, 0)); // Increment uploaded bytes
        ProgressBar.Position := Round(1000 * (CurrentBytes / TotalBytes));
      end;
    HR_Connect: CurrentBytes := 0; // Reset 
    (*
      else
        begin
          v := getEnumName(typeInfo(THookSocketReason),
            integer(Reason)) + ' ' + Value);
          MemoLog.Lines.Add(v); // Show log in a Memo field
        end;
    *)
  end;
end;
 
// Init callback:
 
  ftp := TFTPSend.Create;
  try
    ftp.DSock.OnStatus := SockPutCallBack; // Update progressbar
    ftp.Username := ....
    ...

Download full example-code here: ftpdemo3.zip

public/howto/ftp_progressbar.1271964238.txt.gz · Last modified: 2010/04/22 21:23 by arnulf
Driven by DokuWiki Recent changes RSS feed