Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [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(CurrentPageId: Integer);
- begin
- if CurrentPageId = wpInstalling then
- StartTick := GetTickCount;
- end;
- procedure CancelButtonClick(CurrentPageId: Integer; var Cancel, Confirm: Boolean);
- begin
- if CurrentPageId = 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;
- LastTick: DWORD;
- begin
- LastTick := GetTickCount;
- if (LastTick-CurTick) = 1000 then
- begin
- CurTick := GetTickCount;
- PercentLabel.Caption :=
- Format(ExpandConstant('{cm:done} %.2f %%'), [(CurProgress * 100.0) / MaxProgress]);
- ElapsedLabel.Caption :=
- Format(ExpandConstant('{cm:elapsed} %s'), [TicksToStr(CurTick - StartTick)]);
- if CurProgress > 0 then
- begin
- RemainingLabel.Caption :=
- Format(ExpandConstant('{cm:remaining} %s'), [TicksToStr(
- ((CurTick - StartTick) / CurProgress) * (MaxProgress - CurProgress))]);
- end;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement