Setup.UninstallProgressForm.pas 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. unit Setup.UninstallProgressForm;
  2. {
  3. Inno Setup
  4. Copyright (C) 1997-2025 Jordan Russell
  5. Portions by Martijn Laan
  6. For conditions of distribution and use, see LICENSE.TXT.
  7. Uninstaller progress form
  8. }
  9. interface
  10. uses
  11. Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  12. Setup.SetupForm, StdCtrls, ExtCtrls, BitmapImage, NewProgressBar, NewStaticText,
  13. NewNotebook, BidiCtrls;
  14. type
  15. TUninstallProgressForm = class(TSetupForm)
  16. FOuterNotebook: TNewNotebook;
  17. FInnerPage: TNewNotebookPage;
  18. FInnerNotebook: TNewNotebook;
  19. FInstallingPage: TNewNotebookPage;
  20. FMainPanel: TPanel;
  21. FPageNameLabel: TNewStaticText;
  22. FPageDescriptionLabel: TNewStaticText;
  23. FWizardSmallBitmapImage: TBitmapImage;
  24. FBevel1: TBevel;
  25. FStatusLabel: TNewStaticText;
  26. FProgressBar: TNewProgressBar;
  27. FBeveledLabel: TNewStaticText;
  28. FBevel: TBevel;
  29. FCancelButton: TNewButton;
  30. protected
  31. procedure CreateParams(var Params: TCreateParams); override;
  32. public
  33. constructor Create(AOwner: TComponent); override;
  34. destructor Destroy; override;
  35. procedure Initialize(const ATitle, AAppName: String; const AModernStyle: Boolean);
  36. procedure UpdateProgress(const AProgress, ARange: Integer);
  37. published
  38. property OuterNotebook: TNewNotebook read FOuterNotebook;
  39. property InnerPage: TNewNotebookPage read FInnerPage;
  40. property InnerNotebook: TNewNotebook read FInnerNotebook;
  41. property InstallingPage: TNewNotebookPage read FInstallingPage;
  42. property MainPanel: TPanel read FMainPanel;
  43. property PageNameLabel: TNewStaticText read FPageNameLabel;
  44. property PageDescriptionLabel: TNewStaticText read FPageDescriptionLabel;
  45. property WizardSmallBitmapImage: TBitmapImage read FWizardSmallBitmapImage;
  46. property Bevel1: TBevel read FBevel1;
  47. property StatusLabel: TNewStaticText read FStatusLabel;
  48. property ProgressBar: TNewProgressBar read FProgressBar;
  49. property BeveledLabel: TNewStaticText read FBeveledLabel;
  50. property Bevel: TBevel read FBevel;
  51. property CancelButton: TNewButton read FCancelButton;
  52. end;
  53. var
  54. UninstallProgressForm: TUninstallProgressForm;
  55. implementation
  56. uses
  57. TaskbarProgressFunc, Setup.MainForm, SetupLdrAndSetup.Messages,
  58. Shared.SetupMessageIDs, Shared.CommonFunc.Vcl;
  59. {$R *.DFM}
  60. { TUninstallProgressForm }
  61. procedure UninstallMessageBoxCallback(const Flags: LongInt; const After: Boolean;
  62. const Param: LongInt);
  63. const
  64. States: array [TNewProgressBarState] of TTaskbarProgressState =
  65. (tpsNormal, tpsError, tpsPaused);
  66. var
  67. UninstallProgressForm: TUninstallProgressForm;
  68. NewState: TNewProgressBarState;
  69. begin
  70. UninstallProgressForm := TUninstallProgressForm(Param);
  71. if After then
  72. NewState := npbsNormal
  73. else if (Flags and MB_ICONSTOP) <> 0 then
  74. NewState := npbsError
  75. else
  76. NewState := npbsPaused;
  77. with UninstallProgressForm.ProgressBar do begin
  78. State := NewState;
  79. Invalidate;
  80. end;
  81. SetAppTaskbarProgressState(States[NewState]);
  82. end;
  83. constructor TUninstallProgressForm.Create(AOwner: TComponent);
  84. begin
  85. inherited;
  86. SetMessageBoxCallbackFunc(UninstallMessageBoxCallback, LongInt(Self));
  87. InitializeFont;
  88. MainPanel.ParentBackGround := False;
  89. PageNameLabel.Font.Style := [fsBold];
  90. PageNameLabel.Caption := SetupMessages[msgWizardUninstalling];
  91. if not WizardSmallBitmapImage.InitializeFromIcon(HInstance, 'Z_UNINSTALLICON', MainPanel.Color, [32, 48, 64]) then {don't localize}
  92. WizardSmallBitmapImage.InitializeFromIcon(HInstance, 'MAINICON', MainPanel.Color, [32, 48, 64]); {don't localize}
  93. if SetupMessages[msgBeveledLabel] <> '' then begin
  94. BeveledLabel.Caption := ' ' + SetupMessages[msgBeveledLabel] + ' ';
  95. BeveledLabel.Visible := True;
  96. end;
  97. CancelButton.Caption := SetupMessages[msgButtonCancel];
  98. end;
  99. destructor TUninstallProgressForm.Destroy;
  100. begin
  101. SetMessageBoxCallbackFunc(nil, 0);
  102. SetAppTaskbarProgressState(tpsNoProgress);
  103. inherited;
  104. end;
  105. procedure TUninstallProgressForm.Initialize(const ATitle, AAppName: String; const AModernStyle: Boolean);
  106. begin
  107. Caption := ATitle;
  108. PageDescriptionLabel.Caption := FmtSetupMessage1(msgUninstallStatusLabel, AAppName);
  109. StatusLabel.Caption := FmtSetupMessage1(msgStatusUninstalling, AAppName);
  110. if AModernStyle then begin
  111. OuterNotebook.Color := clWindow;
  112. Bevel1.Visible := False;
  113. end;
  114. end;
  115. procedure TUninstallProgressForm.CreateParams(var Params: TCreateParams);
  116. begin
  117. inherited;
  118. Params.WindowClass.style := Params.WindowClass.style or CS_NOCLOSE;
  119. end;
  120. procedure TUninstallProgressForm.UpdateProgress(const AProgress, ARange: Integer);
  121. var
  122. NewPos: Integer;
  123. begin
  124. NewPos := MulDiv(AProgress, ProgressBar.Max, ARange);
  125. if ProgressBar.Position <> NewPos then begin
  126. ProgressBar.Position := NewPos;
  127. SetAppTaskbarProgressValue(NewPos, ProgressBar.Max);
  128. end;
  129. end;
  130. end.