Browse Source

Cleanup a bit more.

Martijn Laan 7 tháng trước cách đây
mục cha
commit
3a1914add3

+ 1 - 1
Projects/Setup.dpr

@@ -300,7 +300,7 @@ begin
     Application.MainFormOnTaskBar := True;
     InitializeSetup;
     MainForm := TMainForm.Create(Application);
-    MainForm.InitializeWizard;
+    InitializeWizard;
   except
     { Halt on any exception }
     ShowExceptionMsg;

+ 8 - 55
Projects/Src/Setup.MainForm.pas

@@ -5,15 +5,13 @@ unit Setup.MainForm;
   Copyright (C) 1997-2025 Jordan Russell
   Portions by Martijn Laan
   For conditions of distribution and use, see LICENSE.TXT.
-
-  Background form
 }
 
 interface
 
 uses
-  Windows, Messages, SysUtils, Classes,
-  Shared.Struct, Setup.MainFunc, Shared.SetupSteps;
+  Windows, SysUtils, Classes,
+  Shared.SetupSteps;
 
 type
   TMainForm = class(TComponent)
@@ -24,12 +22,10 @@ type
     destructor Destroy; override;
     procedure Close;
     procedure Finish(const FromPreparingPage: Boolean);
-    class procedure InitializeWizard;
     function Install: Boolean;
     procedure SetStep(const AStep: TSetupStep; const HandleExceptions: Boolean);
     class procedure ShowException(Sender: TObject; E: Exception);
     class procedure ShowExceptionMsg(const S: String);
-    class procedure ShowAboutBox;
   end;
 
 var
@@ -38,10 +34,12 @@ var
 implementation
 
 uses
-  Forms, Graphics, ShlObj, SHA256, RestartManager,
-  Shared.CommonFunc, Shared.CommonFunc.Vcl, Shared.SetupMessageIDs,
-  SetupLdrAndSetup.Messages, SetupLdrAndSetup.RedirFunc, Setup.Install,
-  Setup.InstFunc, Setup.WizardForm, Setup.LoggingFunc, Shared.SetupTypes;
+  Messages, ShlObj,
+  Forms,
+  SHA256, RestartManager,
+  Shared.Struct, Shared.CommonFunc, Shared.CommonFunc.Vcl, Shared.SetupMessageIDs,
+  SetupLdrAndSetup.Messages, Setup.Install,
+  Setup.MainFunc, Setup.InstFunc, Setup.WizardForm, Setup.LoggingFunc, Shared.SetupTypes;
 
 destructor TMainForm.Destroy;
 begin
@@ -49,30 +47,6 @@ begin
   inherited;
 end;
 
-class procedure TMainForm.ShowAboutBox;
-begin
-  { Removing the About box or modifying any existing text inside it is a
-    violation of the Inno Setup license agreement; see LICENSE.TXT.
-    However, adding additional lines to the end of the About box is
-    permitted. }
-  var S := SetupTitle + ' version ' + SetupVersion + SNewLine;
-  if SetupTitle <> 'Inno Setup' then
-    S := S + (SNewLine + 'Based on Inno Setup' + SNewLine);
-  S := S + ('Copyright (C) 1997-2025 Jordan Russell' + SNewLine +
-    'Portions Copyright (C) 2000-2025 Martijn Laan' + SNewLine +
-    'All rights reserved.' + SNewLine2 +
-    'Inno Setup home page:' + SNewLine +
-    'https://www.innosetup.com/');
-  S := S + SNewLine2 + 'RemObjects Pascal Script home page:' + SNewLine +
-    'https://www.remobjects.com/ps';
-  if SetupMessages[msgAboutSetupNote] <> '' then
-    S := S + SNewLine2 + SetupMessages[msgAboutSetupNote];
-  if SetupMessages[msgTranslatorNote] <> '' then
-    S := S + SNewLine2 + SetupMessages[msgTranslatorNote];
-  StringChangeEx(S, '(C)', #$00A9, True);
-  LoggedMsgBox(S, SetupMessages[msgAboutSetupTitle], mbInformation, MB_OK, False, 0);
-end;
-
 class procedure TMainForm.ShowExceptionMsg(const S: String);
 begin
   Log('Exception message:');
@@ -103,27 +77,6 @@ begin
   end;
 end;
 
-class procedure TMainForm.InitializeWizard;
-begin
-  WizardForm := AppCreateForm(TWizardForm) as TWizardForm;
-  if CodeRunner <> nil then begin
-    try
-      CodeRunner.RunProcedures('InitializeWizard', [''], False);
-    except
-      Log('InitializeWizard raised an exception (fatal).');
-      raise;
-    end;
-  end;
-  WizardForm.FlipSizeAndCenterIfNeeded(False, nil, False);
-  WizardForm.SetCurPage(wpWelcome);
-  if InstallMode = imNormal then begin
-    WizardForm.ClickToStartPage; { this won't go past wpReady  }
-    WizardForm.Visible := True;
-  end
-  else
-    WizardForm.ClickThroughPages;
-end;
-
 procedure TerminateApp;
 begin
   { Work around shell32 bug: Don't use PostQuitMessage/Application.Terminate

+ 22 - 0
Projects/Src/Setup.MainFunc.pas

@@ -186,6 +186,7 @@ procedure Initialize64BitInstallMode(const A64BitInstallMode: Boolean);
 procedure Log64BitInstallMode;
 procedure InitializeCommonVars;
 procedure InitializeSetup;
+procedure InitializeWizard;
 procedure InitMainNonSHFolderConsts;
 function InstallOnThisVersion(const MinVersion: TSetupVersionData;
   const OnlyBelowVersion: TSetupVersionData): TInstallOnThisVersionResult;
@@ -3392,6 +3393,27 @@ begin
   end;
 end;
 
+procedure InitializeWizard;
+begin
+  WizardForm := AppCreateForm(TWizardForm) as TWizardForm;
+  if CodeRunner <> nil then begin
+    try
+      CodeRunner.RunProcedures('InitializeWizard', [''], False);
+    except
+      Log('InitializeWizard raised an exception (fatal).');
+      raise;
+    end;
+  end;
+  WizardForm.FlipSizeAndCenterIfNeeded(False, nil, False);
+  WizardForm.SetCurPage(wpWelcome);
+  if InstallMode = imNormal then begin
+    WizardForm.ClickToStartPage; { this won't go past wpReady  }
+    WizardForm.Visible := True;
+  end
+  else
+    WizardForm.ClickThroughPages;
+end;
+
 procedure DeinitSetup(const AllowCustomSetupExitCode: Boolean);
 var
   I: Integer;

+ 0 - 8
Projects/Src/Setup.ScriptFunc.HelperFunc.pas

@@ -51,7 +51,6 @@ var
 
 procedure NoUninstallFuncError(const C: AnsiString); overload;
 procedure OnlyUninstallFuncError(const C: AnsiString); overload;
-function GetMainForm: TMainForm;
 function GetWizardForm: TWizardForm;
 function GetUninstallProgressForm: TUninstallProgressForm;
 function GetMsgBoxCaption: String;
@@ -110,13 +109,6 @@ begin
   InternalError(Format('Cannot call "%s" function during Setup', [C]));
 end;
 
-function GetMainForm: TMainForm;
-begin
-  Result := MainForm;
-  if Result = nil then
-    InternalError('An attempt was made to access MainForm before it has been created'); 
-end;
-
 function GetWizardForm: TWizardForm;
 begin
   Result := WizardForm;

+ 2 - 2
Projects/Src/Setup.ScriptFunc.pas

@@ -28,7 +28,7 @@ uses
   SetupLdrAndSetup.Messages, Shared.SetupMessageIDs, Setup.NewDiskForm,
   Setup.WizardForm, Shared.VerInfoFunc, Shared.SetupTypes,
   Shared.Int64Em, Setup.LoggingFunc, Setup.SetupForm, Setup.RegDLL, Setup.Helper,
-  Setup.SpawnClient, Setup.DotNetFunc,
+  Setup.SpawnClient, Setup.DotNetFunc, Setup.MainForm,
   Shared.DotNetVersion, Setup.MsiFunc, Compression.SevenZipDecoder,
   Setup.DebugClient, Shared.ScriptFunc, Setup.ScriptFunc.HelperFunc;
 
@@ -1692,7 +1692,7 @@ var
     end);
     RegisterScriptFunc('SHOWEXCEPTIONMESSAGE', procedure(const Caller: TPSExec; const OrgName: AnsiString; const Stack: TPSStack; const PStart: Cardinal)
     begin
-      GetMainForm.ShowExceptionMsg(AddPeriod(GetExceptionMessage(Caller)));
+      TMainForm.ShowExceptionMsg(AddPeriod(GetExceptionMessage(Caller)));
     end);
     RegisterScriptFunc('TERMINATED', procedure(const Caller: TPSExec; const OrgName: AnsiString; const Stack: TPSStack; const PStart: Cardinal)
     begin

+ 22 - 3
Projects/Src/Setup.WizardForm.pas

@@ -2681,9 +2681,28 @@ end;
 
 procedure TWizardForm.WMSysCommand(var Message: TWMSysCommand);
 begin
-  if Message.CmdType = 9999 then
-    MainForm.ShowAboutBox
-  else
+  if Message.CmdType = 9999 then begin
+    { Removing the About box or modifying any existing text inside it is a
+      violation of the Inno Setup license agreement; see LICENSE.TXT.
+      However, adding additional lines to the end of the About box is
+      permitted. }
+    var S := SetupTitle + ' version ' + SetupVersion + SNewLine;
+    if SetupTitle <> 'Inno Setup' then
+      S := S + (SNewLine + 'Based on Inno Setup' + SNewLine);
+    S := S + ('Copyright (C) 1997-2025 Jordan Russell' + SNewLine +
+      'Portions Copyright (C) 2000-2025 Martijn Laan' + SNewLine +
+      'All rights reserved.' + SNewLine2 +
+      'Inno Setup home page:' + SNewLine +
+      'https://www.innosetup.com/');
+    S := S + SNewLine2 + 'RemObjects Pascal Script home page:' + SNewLine +
+      'https://www.remobjects.com/ps';
+    if SetupMessages[msgAboutSetupNote] <> '' then
+      S := S + SNewLine2 + SetupMessages[msgAboutSetupNote];
+    if SetupMessages[msgTranslatorNote] <> '' then
+      S := S + SNewLine2 + SetupMessages[msgTranslatorNote];
+    StringChangeEx(S, '(C)', #$00A9, True);
+    LoggedMsgBox(S, SetupMessages[msgAboutSetupTitle], mbInformation, MB_OK, False, 0)
+  end else
     inherited;
 end;