Setup.UninstallProgressForm.pas 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. unit Setup.UninstallProgressForm;
  2. {
  3. Inno Setup
  4. Copyright (C) 1997-2024 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. private
  31. { Private declarations }
  32. protected
  33. procedure CreateParams(var Params: TCreateParams); override;
  34. public
  35. { Public declarations }
  36. constructor Create(AOwner: TComponent); override;
  37. destructor Destroy; override;
  38. procedure Initialize(const ATitle, AAppName: String; const AModernStyle: Boolean);
  39. procedure UpdateProgress(const AProgress, ARange: Integer);
  40. published
  41. property OuterNotebook: TNewNotebook read FOuterNotebook;
  42. property InnerPage: TNewNotebookPage read FInnerPage;
  43. property InnerNotebook: TNewNotebook read FInnerNotebook;
  44. property InstallingPage: TNewNotebookPage read FInstallingPage;
  45. property MainPanel: TPanel read FMainPanel;
  46. property PageNameLabel: TNewStaticText read FPageNameLabel;
  47. property PageDescriptionLabel: TNewStaticText read FPageDescriptionLabel;
  48. property WizardSmallBitmapImage: TBitmapImage read FWizardSmallBitmapImage;
  49. property Bevel1: TBevel read FBevel1;
  50. property StatusLabel: TNewStaticText read FStatusLabel;
  51. property ProgressBar: TNewProgressBar read FProgressBar;
  52. property BeveledLabel: TNewStaticText read FBeveledLabel;
  53. property Bevel: TBevel read FBevel;
  54. property CancelButton: TNewButton read FCancelButton;
  55. end;
  56. var
  57. UninstallProgressForm: TUninstallProgressForm;
  58. implementation
  59. uses
  60. TaskbarProgressFunc, Setup.MainForm, SetupLdrAndSetup.Messages,
  61. Shared.SetupMessageIDs, Shared.CommonFunc.Vcl;
  62. {$R *.DFM}
  63. { TUninstallProgressForm }
  64. procedure UninstallMessageBoxCallback(const Flags: LongInt; const After: Boolean;
  65. const Param: LongInt);
  66. const
  67. States: array [TNewProgressBarState] of TTaskbarProgressState =
  68. (tpsNormal, tpsError, tpsPaused);
  69. var
  70. UninstallProgressForm: TUninstallProgressForm;
  71. NewState: TNewProgressBarState;
  72. begin
  73. UninstallProgressForm := TUninstallProgressForm(Param);
  74. if After then
  75. NewState := npbsNormal
  76. else if (Flags and MB_ICONSTOP) <> 0 then
  77. NewState := npbsError
  78. else
  79. NewState := npbsPaused;
  80. with UninstallProgressForm.ProgressBar do begin
  81. State := NewState;
  82. Invalidate;
  83. end;
  84. SetAppTaskbarProgressState(States[NewState]);
  85. end;
  86. constructor TUninstallProgressForm.Create(AOwner: TComponent);
  87. begin
  88. inherited;
  89. SetMessageBoxCallbackFunc(UninstallMessageBoxCallback, LongInt(Self));
  90. InitializeFont;
  91. MainPanel.ParentBackGround := False;
  92. PageNameLabel.Font.Style := [fsBold];
  93. PageNameLabel.Caption := SetupMessages[msgWizardUninstalling];
  94. if not WizardSmallBitmapImage.InitializeFromIcon(HInstance, 'Z_UNINSTALLICON', MainPanel.Color, [32, 48, 64]) then {don't localize}
  95. WizardSmallBitmapImage.InitializeFromIcon(HInstance, 'MAINICON', MainPanel.Color, [32, 48, 64]); {don't localize}
  96. if SetupMessages[msgBeveledLabel] <> '' then begin
  97. BeveledLabel.Caption := ' ' + SetupMessages[msgBeveledLabel] + ' ';
  98. BeveledLabel.Visible := True;
  99. end;
  100. CancelButton.Caption := SetupMessages[msgButtonCancel];
  101. end;
  102. destructor TUninstallProgressForm.Destroy;
  103. begin
  104. SetMessageBoxCallbackFunc(nil, 0);
  105. SetAppTaskbarProgressState(tpsNoProgress);
  106. inherited;
  107. end;
  108. procedure TUninstallProgressForm.Initialize(const ATitle, AAppName: String; const AModernStyle: Boolean);
  109. begin
  110. Caption := ATitle;
  111. PageDescriptionLabel.Caption := FmtSetupMessage1(msgUninstallStatusLabel, AAppName);
  112. StatusLabel.Caption := FmtSetupMessage1(msgStatusUninstalling, AAppName);
  113. if AModernStyle then begin
  114. OuterNotebook.Color := clWindow;
  115. Bevel1.Visible := False;
  116. end;
  117. end;
  118. procedure TUninstallProgressForm.CreateParams(var Params: TCreateParams);
  119. begin
  120. inherited;
  121. Params.WindowClass.style := Params.WindowClass.style or CS_NOCLOSE;
  122. end;
  123. procedure TUninstallProgressForm.UpdateProgress(const AProgress, ARange: Integer);
  124. var
  125. NewPos: Integer;
  126. begin
  127. NewPos := MulDiv(AProgress, ProgressBar.Max, ARange);
  128. if ProgressBar.Position <> NewPos then begin
  129. ProgressBar.Position := NewPos;
  130. SetAppTaskbarProgressValue(NewPos, ProgressBar.Max);
  131. end;
  132. end;
  133. end.