如何显示完成百分比,经过时间和估计时间进度? [英] How to show percent done, elapsed time and estimated time progress?
本文介绍了如何显示完成百分比,经过时间和估计时间进度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想显示安装过程中完成的百分比,经过的时间和估计的时间值.是否可以添加以下屏幕快照中标记的文本标签?
I would like to show percent done, elapsed time and estimated time values for the installation process. Is there a way to add text labels whose are marked in the below screenshot ?
推荐答案
It was not that easy to implement this feature before the CurInstallProgressChanged
event method was introduced in Inno Setup 5.5.4. But now, having this event available, you can write a script like this:
特别感谢 user1662035 提出的解决在回滚过程中隐藏标签的建议.
Special thanks to user1662035 for the proposed idea for the fix of hiding labels at rollback process.
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Files]
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.chm"; DestDir: "{app}"
Source: "Readme.txt"; DestDir: "{app}"
[Code]
function GetTickCount: DWORD;
external 'GetTickCount@kernel32.dll stdcall';
var
StartTick: DWORD;
PercentLabel: TNewStaticText;
ElapsedLabel: TNewStaticText;
RemainingLabel: TNewStaticText;
function TicksToStr(Value: DWORD): string;
var
I: DWORD;
Hours, Minutes, Seconds: Integer;
begin
I := Value div 1000;
Seconds := I mod 60;
I := I div 60;
Minutes := I mod 60;
I := I div 60;
Hours := I mod 24;
Result := Format('%.2d:%.2d:%.2d', [Hours, Minutes, Seconds]);
end;
procedure InitializeWizard;
begin
PercentLabel := TNewStaticText.Create(WizardForm);
PercentLabel.Parent := WizardForm.ProgressGauge.Parent;
PercentLabel.Left := 0;
PercentLabel.Top := WizardForm.ProgressGauge.Top +
WizardForm.ProgressGauge.Height + 12;
ElapsedLabel := TNewStaticText.Create(WizardForm);
ElapsedLabel.Parent := WizardForm.ProgressGauge.Parent;
ElapsedLabel.Left := 0;
ElapsedLabel.Top := PercentLabel.Top + PercentLabel.Height + 4;
RemainingLabel := TNewStaticText.Create(WizardForm);
RemainingLabel.Parent := WizardForm.ProgressGauge.Parent;
RemainingLabel.Left := 0;
RemainingLabel.Top := ElapsedLabel.Top + ElapsedLabel.Height + 4;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpInstalling then
StartTick := GetTickCount;
end;
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
if CurPageID = wpInstalling then
begin
Cancel := False;
if ExitSetupMsgBox then
begin
Cancel := True;
Confirm := False;
PercentLabel.Visible := False;
ElapsedLabel.Visible := False;
RemainingLabel.Visible := False;
end;
end;
end;
procedure CurInstallProgressChanged(CurProgress, MaxProgress: Integer);
var
CurTick: DWORD;
begin
CurTick := GetTickCount;
PercentLabel.Caption :=
Format('Done: %.2f %%', [(CurProgress * 100.0) / MaxProgress]);
ElapsedLabel.Caption :=
Format('Elapsed: %s', [TicksToStr(CurTick - StartTick)]);
if CurProgress > 0 then
begin
RemainingLabel.Caption :=
Format('Remaining: %s', [TicksToStr(
((CurTick - StartTick) / CurProgress) * (MaxProgress - CurProgress))]);
end;
end;
这篇关于如何显示完成百分比,经过时间和估计时间进度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文