Advertisement
stonemaster

Untitled

Sep 26th, 2015
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 2.41 KB | None | 0 0
  1. [Code]
  2. function GetTickCount: DWORD;
  3.   external 'GetTickCount@kernel32.dll stdcall';
  4.  
  5. var
  6.   StartTick: DWORD;
  7.   PercentLabel: TNewStaticText;
  8.   ElapsedLabel: TNewStaticText;
  9.   RemainingLabel: TNewStaticText;
  10.  
  11. function TicksToStr(Value: DWORD): string;
  12. var
  13.   I: DWORD;
  14.   Hours, Minutes, Seconds: Integer;
  15. begin
  16.   I := Value div 1000;
  17.   Seconds := I mod 60;
  18.   I := I div 60;
  19.   Minutes := I mod 60;
  20.   I := I div 60;
  21.   Hours := I mod 24;
  22.   Result := Format('%.2d:%.2d:%.2d', [Hours, Minutes, Seconds]);
  23. end;
  24.  
  25. procedure InitializeWizard;
  26. begin
  27.   PercentLabel := TNewStaticText.Create(WizardForm);
  28.   PercentLabel.Parent := WizardForm.ProgressGauge.Parent;
  29.   PercentLabel.Left := 0;
  30.   PercentLabel.Top := WizardForm.ProgressGauge.Top +
  31.     WizardForm.ProgressGauge.Height + 12;
  32.  
  33.   ElapsedLabel := TNewStaticText.Create(WizardForm);
  34.   ElapsedLabel.Parent := WizardForm.ProgressGauge.Parent;
  35.   ElapsedLabel.Left := 0;
  36.   ElapsedLabel.Top := PercentLabel.Top + PercentLabel.Height + 4;
  37.  
  38.   RemainingLabel := TNewStaticText.Create(WizardForm);
  39.   RemainingLabel.Parent := WizardForm.ProgressGauge.Parent;
  40.   RemainingLabel.Left := 0;
  41.   RemainingLabel.Top := ElapsedLabel.Top + ElapsedLabel.Height + 4;
  42. end;
  43.  
  44. procedure CurPageChanged(CurrentPageId: Integer);
  45. begin
  46.   if CurrentPageId = wpInstalling then
  47.     StartTick := GetTickCount;
  48. end;
  49.  
  50. procedure CancelButtonClick(CurrentPageId: Integer; var Cancel, Confirm: Boolean);
  51. begin
  52.   if CurrentPageId = wpInstalling then
  53.   begin
  54.     Cancel := False;
  55.     if ExitSetupMsgBox then
  56.     begin
  57.       Cancel := True;
  58.       Confirm := False;
  59.       PercentLabel.Visible := False;
  60.       ElapsedLabel.Visible := False;
  61.       RemainingLabel.Visible := False;
  62.     end;
  63.   end;
  64. end;
  65.  
  66. procedure CurInstallProgressChanged(CurProgress, MaxProgress: Integer);
  67. var
  68.   CurTick: DWORD;
  69.   LastTick: DWORD;
  70.  
  71. begin
  72.   LastTick := GetTickCount;
  73.   if (LastTick-CurTick) = 1000 then
  74.   begin
  75.   CurTick := GetTickCount;
  76.   PercentLabel.Caption :=
  77.     Format(ExpandConstant('{cm:done} %.2f %%'), [(CurProgress * 100.0) / MaxProgress]);
  78.   ElapsedLabel.Caption :=
  79.     Format(ExpandConstant('{cm:elapsed} %s'), [TicksToStr(CurTick - StartTick)]);
  80.      if CurProgress > 0 then
  81.       begin
  82.       RemainingLabel.Caption :=
  83.       Format(ExpandConstant('{cm:remaining} %s'), [TicksToStr(
  84.         ((CurTick - StartTick) / CurProgress) * (MaxProgress - CurProgress))]);
  85.       end;
  86.   end;
  87. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement