文件拷贝时的进度表为什么不显示(100分)

  • 主题发起人 主题发起人 bigrichcat
  • 开始时间 开始时间
B

bigrichcat

Unregistered / Unconfirmed
GUEST, unregistred user!
我在书上抄了一段程序,拷贝文件时显示进度条,可是进度条不显示进度,一直到拷贝结束
才显示直接到了100%,请指教
repeat
BlockRead(SrcFile, Buffer, SizeOf(Buffer), BytesRead);
if BytesRead > 0 then
begin
BlockWrite(DestFile, Buffer, BytesRead, BytesWritten);
if BytesRead <> BytesWritten then
raise Exception.Create('拷贝文件错误')
else begin
TotalRead := TotalRead + BytesRead;
//fcopy.prbCopy.Position := Trunc(TotalRead / Fsize) * 100;
//fcopy.prbCopy.Update;
prbCopy.Position := Trunc(TotalRead / Fsize) * 100;
end;
end
until BytesRead = 0;
 
repeat
BlockRead(SrcFile, Buffer, SizeOf(Buffer), BytesRead);
if BytesRead > 0 then
begin
BlockWrite(DestFile, Buffer, BytesRead, BytesWritten);
if BytesRead <> BytesWritten then
raise Exception.Create('拷贝文件错误')
else begin
TotalRead := TotalRead + BytesRead;
//fcopy.prbCopy.Position := Trunc(TotalRead / Fsize) * 100;
//fcopy.prbCopy.Update;
prbCopy.Position := Trunc(TotalRead / Fsize) * 100;
[red]Application.ProcessMessages;//加这一句试试[/red]
end;
end
until BytesRead = 0;
 
Application.ProcessMessages
 
Application.ProcessMessages;
prbCopy.Position := Trunc(TotalRead / Fsize) * 100;
 
repeat
BlockRead(SrcFile, Buffer, SizeOf(Buffer), BytesRead);
if BytesRead > 0 then
begin
BlockWrite(DestFile, Buffer, BytesRead, BytesWritten);
if BytesRead <> BytesWritten then
raise Exception.Create('拷贝文件错误')
else begin
TotalRead := TotalRead + BytesRead;
//fcopy.prbCopy.Position := Trunc(TotalRead / Fsize) * 100;
//fcopy.prbCopy.Update;
prbCopy.Position := Trunc(TotalRead / Fsize) * 100;
Application.processmessage;//加上﹐然后找個大文件來試﹐小文件一閃就過了。
end;
end
until BytesRead = 0;
還有prbCopy.Min和Max要先賦值好﹐特別是Max。
 
首先谢谢诸位的热心

我试了,可还是不好使,希望您们能够亲自试一试
 
或者把那一句变为self.update。
 
后退
顶部