TFtpClient.OnProgress

From Overbyte
Revision as of 16:42, 7 November 2006 by Frla (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Main page -> ICS components reference -> THttpCli -> OnProgress

Definition

procedure(Sender: TObject; Count : LongInt; var Abort : Boolean) of object;


  • Sender : the client which fired the event
  • Count : the filesize count
  • Abort : Used to abort the transfer

Description

This event fires to indicate the fileprogress.

Example

Before you transfer the file retrieve the filesize and set it to the progressbar max property:

Progress.Max := getFileSize(FilenameEdit.Text);

In the event of progress do something like this:

procedure TMainForm.FtpClientProgress(Sender: TObject; Count: Integer; var Abort: Boolean);
begin
  Progress.Position := Count;
end;


This is the getFileSize-function

function getFileSize(pFileName: string): longint;
var
  sr: TSearchRec;
  FileAttrs: Integer;
begin
  FileAttrs := faReadOnly;
  FileAttrs := FileAttrs + faHidden;
  FileAttrs := FileAttrs + faSysFile;
  FileAttrs := FileAttrs + faVolumeID;
  FileAttrs := FileAttrs + faDirectory;
  FileAttrs := FileAttrs + faArchive;
  FileAttrs := FileAttrs + faAnyFile;
  if FindFirst(pFileName, FileAttrs, sr) = 0 then
  begin
    Result := sr.Size;
    FindClose(sr);
  end
  else
    Result := 0;
end;

Best practices

nothing yet