Geir Baardsen
2004-08-17 06:27:24 UTC
Hi! I have a form where the user can copy a file. I'm trying to
understand the gauge, writing the text and so on. Could anybody tell
me how to update a gauge, and how to manipulate the caption of the
Gauge in the following procedure?
procedure TfrmCopyCat.CopyFileClick(Sender: TObject);
var
OpStruct : TSHFileOpStruct;
FromBuf, ToBuf : Array[0..255] of Char;
LocFrom,LocTo,f : string;
RetVal : integer;
begin
f := 'D:\Autoexec.bat';
LocFrom := 'C:\Autoexec.bat';
LocTo := 'D:\';
RetVal := MessageDlg(
'You are about to copy' +#13+
'from: ' + '[' + LocFrom + ']' +#13+
'to: ' + '[' + LocTo + ']' +#13+
'All similar files will be deleted in-> ' + '[' + LocTo + ']' +#13+
'U sure?',mtInformation,[mbNo,mbYes],0);
case RetVal of
idNo:begin
Abort;
end;
idYes:begin
{I want the gauge to start here, but what value should I use to update
the progress of the gauge?}
DelDir(LocTo);
try
FillChar(OpStruct,SizeOf(OpStruct),0);
FillChar(FromBuf,SizeOf(FromBuf),0);
FillChar(ToBuf,SizeOf(ToBuf),0);
StrPCopy(FromBuf,LocFrom);
StrPCopy(ToBuf,LocTo);
except
FillChar(OpStruct,SizeOf(nil),0);
end;
with OpStruct do
begin
try
Wnd := 0;
wFunc := FO_COPY;
pFrom := @FromBuf;
pTo := @ToBuf;
fFlags := FOF_NOCONFIRMMKDIR;
fAnyOperationsAborted := False;
hNameMappings := nil;
lpszProgressTitle := nil;
except
;
end;
end;
ShFileOperation(OpStruct);
if FileExists(f) then
begin
ShowMessage('Copied ' + #13+
f + '!');
end
else
ShowMessage('Did not find ' + ' ' + f);
end;
end;
end;
end;
understand the gauge, writing the text and so on. Could anybody tell
me how to update a gauge, and how to manipulate the caption of the
Gauge in the following procedure?
procedure TfrmCopyCat.CopyFileClick(Sender: TObject);
var
OpStruct : TSHFileOpStruct;
FromBuf, ToBuf : Array[0..255] of Char;
LocFrom,LocTo,f : string;
RetVal : integer;
begin
f := 'D:\Autoexec.bat';
LocFrom := 'C:\Autoexec.bat';
LocTo := 'D:\';
RetVal := MessageDlg(
'You are about to copy' +#13+
'from: ' + '[' + LocFrom + ']' +#13+
'to: ' + '[' + LocTo + ']' +#13+
'All similar files will be deleted in-> ' + '[' + LocTo + ']' +#13+
'U sure?',mtInformation,[mbNo,mbYes],0);
case RetVal of
idNo:begin
Abort;
end;
idYes:begin
{I want the gauge to start here, but what value should I use to update
the progress of the gauge?}
DelDir(LocTo);
try
FillChar(OpStruct,SizeOf(OpStruct),0);
FillChar(FromBuf,SizeOf(FromBuf),0);
FillChar(ToBuf,SizeOf(ToBuf),0);
StrPCopy(FromBuf,LocFrom);
StrPCopy(ToBuf,LocTo);
except
FillChar(OpStruct,SizeOf(nil),0);
end;
with OpStruct do
begin
try
Wnd := 0;
wFunc := FO_COPY;
pFrom := @FromBuf;
pTo := @ToBuf;
fFlags := FOF_NOCONFIRMMKDIR;
fAnyOperationsAborted := False;
hNameMappings := nil;
lpszProgressTitle := nil;
except
;
end;
end;
ShFileOperation(OpStruct);
if FileExists(f) then
begin
ShowMessage('Copied ' + #13+
f + '!');
end
else
ShowMessage('Did not find ' + ' ' + f);
end;
end;
end;
end;