Difference between revisions of "TFtpClient.OnProgress"

From Overbyte
Jump to navigation Jump to search
 
Line 1: Line 1:
 
[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS components reference]]  
 
[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS components reference]]  
-> [[THttpCli]] -> [[TFtpClient.OnProgress | OnProgress]]
+
-> [[TFtpCli]] -> [[TFtpClient.OnProgress | OnProgress]]
 
== Definition ==
 
== Definition ==
 
procedure('''Sender''': TObject; '''Count'''    : LongInt; var '''Abort''' : Boolean) of object;
 
procedure('''Sender''': TObject; '''Count'''    : LongInt; var '''Abort''' : Boolean) of object;

Revision as of 16:42, 7 November 2006

Main page -> ICS components reference -> TFtpCli -> 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