ProgressBar for ftp receive/ send data

Here is some example code for read/ write data:

// CallBack function, add more THookSocketReason events in case ..
 
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.txt · Last modified: 2010/04/22 21:26 by arnulf
Driven by DokuWiki Recent changes RSS feed