UninstProgressForm.pas 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. unit UninstProgressForm;
  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. {$I VERSION.INC}
  11. uses
  12. Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  13. SetupForm, StdCtrls, ExtCtrls, BitmapImage, NewProgressBar, NewStaticText,
  14. NewNotebook, BidiCtrls;
  15. type
  16. TUninstallProgressForm = class(TSetupForm)
  17. FOuterNotebook: TNewNotebook;
  18. FInnerPage: TNewNotebookPage;
  19. FInnerNotebook: TNewNotebook;
  20. FInstallingPage: TNewNotebookPage;
  21. FMainPanel: TPanel;
  22. FPageNameLabel: TNewStaticText;
  23. FPageDescriptionLabel: TNewStaticText;
  24. FWizardSmallBitmapImage: TBitmapImage;
  25. FBevel1: TBevel;
  26. FStatusLabel: TNewStaticText;
  27. FProgressBar: TNewProgressBar;
  28. FBeveledLabel: TNewStaticText;
  29. FBevel: TBevel;
  30. FCancelButton: TNewButton;
  31. private
  32. { Private declarations }
  33. protected
  34. procedure CreateParams(var Params: TCreateParams); override;
  35. public
  36. { Public declarations }
  37. constructor Create(AOwner: TComponent); override;
  38. destructor Destroy; override;
  39. procedure Initialize(const ATitle, AAppName: String; const AModernStyle: Boolean);
  40. procedure UpdateProgress(const AProgress, ARange: Integer);
  41. published
  42. property OuterNotebook: TNewNotebook read FOuterNotebook;
  43. property InnerPage: TNewNotebookPage read FInnerPage;
  44. property InnerNotebook: TNewNotebook read FInnerNotebook;
  45. property InstallingPage: TNewNotebookPage read FInstallingPage;
  46. property MainPanel: TPanel read FMainPanel;
  47. property PageNameLabel: TNewStaticText read FPageNameLabel;
  48. property PageDescriptionLabel: TNewStaticText read FPageDescriptionLabel;
  49. property WizardSmallBitmapImage: TBitmapImage read FWizardSmallBitmapImage;
  50. property Bevel1: TBevel read FBevel1;
  51. property StatusLabel: TNewStaticText read FStatusLabel;
  52. property ProgressBar: TNewProgressBar read FProgressBar;
  53. property BeveledLabel: TNewStaticText read FBeveledLabel;
  54. property Bevel: TBevel read FBevel;
  55. property CancelButton: TNewButton read FCancelButton;
  56. end;
  57. var
  58. UninstallProgressForm: TUninstallProgressForm;
  59. implementation
  60. uses
  61. TaskbarProgressFunc, Main, Msgs, MsgIDs, CmnFunc;
  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.