【发布时间】:2016-12-02 17:02:05
【问题描述】:
我忘记了如何在 Inno Setup 中根据条件正确更新进度条,我写了一个代码来更新我在 Wizard 中创建的进度条。
问题是我在 ProgressBar 的最后一个位置获得 95、96、97、98 或 100、101,并且在我运行安装程序时它的更新不时相同。而且我用来划分的值(这里是 6)不会在所有系统上类似地工作,因为它们的性能与每个系统都非常不同。
我想知道一种正确更新进度条而不会出现此类问题的方法。
[Files]
Source: "C:\Program Files (x86)\Inno Setup 5\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\InnoCallback.dll"; DestDir: "{app}"; Flags: ignoreversion
[Code]
Type
TTimerProc = procedure(HandleW, msg, idEvent, TimeSys: LongWord);
function SetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc: LongWord): LongWord; external 'SetTimer@User32.dll stdcall';
function WrapTimerProc(Callback: TTimerProc; ParamCount: Integer): LongWord; external 'wrapcallback@{tmp}\InnoCallback.dll stdcall delayload';
function KillTimer(hWnd, nIDEvent: LongWord): LongWord; external 'KillTimer@User32.dll stdcall';
var
TTimer: LongWord;
ConditionTracker: String;
P: Integer;
TestingPB: TNewProgressBar;
procedure Install;
var
ErrorCode: Integer;
begin
if ShellExec('Open', 'Timeout.exe', '/T 10', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode) = True then
ConditionTracker := 'DONE';
end;
procedure UpdateProgressBar(HandleW, msg, idEvent, TimeSys: LongWord);
begin
if ConditionTracker = 'DONE' then begin
KillTimer( 0, TTimer);
TestingPB.State := npbsPaused;
end else begin
P := P + 1;
Log('ProgressBar Position: ' + IntToStr(P div 6));
TestingPB.Position := P div 6;
if (P div 6) = 100 then P := 600;
end;
end;
procedure InitializeWizard;
begin
TestingPB := TNewProgressBar.Create(WizardForm);
with TestingPB do begin
Parent := WizardForm;
Width := WizardForm.ProgressGauge.Width;
Top := 200;
Left := (WizardForm.ClientWidth - Width) div 2;
Max := 100;
Position := 0;
Hide;
ExtractTemporaryFile('InnoCallback.dll');
P := 0;
end;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpSelectTasks then begin
TestingPB.Show;
TTimer := SetTimer( 0, 0, 0, WrapTimerProc(@UpdateProgressBar, 4));
Install;
end else
TestingPB.Hide;
end;
提前致谢。
【问题讨论】:
标签: progress-bar inno-setup pascalscript