TProgressbar的问题

eyusir 2004-08-16 10:58:18
我现在执行copyFile,
请问TProgressbar怎样成比例增加直至复制完成,
并显示0%到复制完后显示100%
象windows复制文件一样
...全文
201 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
墨梅无痕 2004-08-16
  • 打赏
  • 举报
回复
提供两个函数供参考:
CopyFileEx(),CopyProgressRoutine()

用 CopyFile 无法得知文件复制的进度。
kaguo 2004-08-16
  • 打赏
  • 举报
回复
TProgressbar没?%进度
Sample 版面 上 TGauge有,看你需要...
hthunter 2004-08-16
  • 打赏
  • 举报
回复
//一下代码是拷贝一个目录的文件到另外一个目录
//拷贝过程会自动调用windows拷贝文件的进度窗口
//仅供参考

uses shellapi, INIFiles;

var
OpStruc: TSHFileOpStruct;
frombuf, tobuf: Array [0..255] of Char;
iniFile: TIniFile;
sSource, sDestination: String;
Begin
iniFile := TIniFile.Create('.\Settings.ini');
try
Application.ProcessMessages;

sSource := iniFile.ReadString('Paths', 'Source', '');
sDestination := iniFile.ReadString('Paths', 'Destination', '');
if (not DirectoryExists(sSource))
or (not DirectoryExists(sDestination)) then
Abort;

if (iniFile.ReadInteger('Paths', 'CreateNewDir', 1) = 1) then
begin
sDestination := sDestination + '\' +
StringReplace(FormatDateTime('yyyy-mm-dd, hh:mm', Now), ':', ':', [rfReplaceAll]);
if (not CreateDir(sDestination)) then
Abort;
end;

FillChar(frombuf, Sizeof(frombuf), 0);
FillChar(tobuf, Sizeof(tobuf), 0);
StrPCopy(frombuf, sSource + '\*.*');
StrPCopy(tobuf, sDestination);
With OpStruc DO Begin
Wnd := Handle;
wFunc := FO_COPY;
pFrom := @frombuf;
pTo := @tobuf;
fFlags := FOF_NOCONFIRMATION or FOF_RENAMEONCOLLISION;
fAnyOperationsAborted := False;
hNameMappings := Nil;
lpszProgressTitle := Nil;
end;
ShFileOperation(OpStruc);
finally
iniFile.Free;
FCanClose := True;
Self.Close;
end;
end;

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧