DerkEimers
asked on
Passing a progressbar to a procedure
I made a function to copy files from hdd to floppy and want to use a progressbar.
procedure CopyFile(Source, Destionation : string; Progressbar);
But I dunno how to pass the progressbar.. Anyone?
procedure CopyFile(Source, Destionation : string; Progressbar);
But I dunno how to pass the progressbar.. Anyone?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept jsweby's comment as answer
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Thank you,
Russell
EE Cleanup Volunteer
I will leave a recommendation in the Cleanup topic area that this question is:
Accept jsweby's comment as answer
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Thank you,
Russell
EE Cleanup Volunteer
use shfileoperation from shellapi:
this is the api that windows/explorer uses and automatically shows the progressbar.
uses ShellAPI;
function CopyAllFiles(sFrom, sTo: string; Protect: boolean): boolean;
var
F: TShFileOpStruct;
ResultVal: integer;
tmp1, tmp2: string;
begin
FillChar(F, SizeOf(F), #0);
Screen.Cursor := crHourGlass;
try
F.Wnd := 0;
F.wFunc := FO_COPY;
tmp1 := sFrom + #0;
tmp2 := sTo + #0;
F.pFrom := PChar(tmp1);
F.pTo := PChar(tmp2);
if Protect then
F.fFlags := FOF_RENAMEONCOLLISION or FOF_SIMPLEPROGRESS
else
F.fFlags := FOF_SIMPLEPROGRESS;
F.fAnyOperationsAborted := False;
F.hNameMappings := nil;
Resultval := ShFileOperation(F);
Result := (ResultVal = 0);
finally
Screen.Cursor := crDefault;
end;
end;
procedure TForm1.Button1Click(Sender
begin
CopyAllFiles('a:\','c:\tem
end;