Use the "SHFileOpStruct" command to do your copy. It will show the
default Windows progress status you see when copying, moving, deleting,
etc within Windows.
 
:-)
 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of rodveilleux
Sent: Monday, 28 May 2007 12:42
To: [email protected]
Subject: [delphi-en] Copy File Progress Bar



Hello,
Trying to display a progress bar in Delphi 2006 while copying a 
large file. My example consists of a VCL Form, 
Button,OpenDialog,Gauge and Timer.
My problem is: The bar will not progress while Copy function is 
executing.

Thanks,
Rodney

Here is my code:

procedure TForm1.Button1Click(Sender: TObject);
var
FromFile,
ToFile,
Path : string;
begin
if OpenDialog1.Execute then
begin {Create back up copy of DBF file}
Path:= ExtractFilePath(OpenDialog1.FileName);
FromFile:= OpenDialog1.FileName;
ToFile:= Path+'Copy of '+ ExtractFileName(FromFile);
Gauge1.MinValue:= 0;
Gauge1.MaxValue:= 10;
Gauge1.Progress:= Gauge1.MinValue;
Timer1.Enabled:= true;
CopyFile(PChar(FromFile),PChar(ToFile),False);
end;
ShowMessage('Complete');
Timer1.Enabled:= False;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
with Gauge1 do
if (Progress < MaxValue) then Progress:= Progress + 1
else Progress:= 0;
Application.ProcessMessages;
end;



 


[Non-text portions of this message have been removed]

Reply via email to