Преглед изворни кода

Setup: De-form TMainForm and set MainFormOnTaskBar=True.

Mostly done, I think. Still need to actually remove shWindowVisible etc. Still some Application.Handle references that need to be cleaned out. Still need to update help.

TMainForm still exists, but is no longer a form. Good enough for now.

With Application.MainFormOnTaskBar=True, we now have a working taskbar thumbnail and proper minimize/restore animations. Finally.

Jordan Russell пре 9 месеци
родитељ
комит
9d52a24040

+ 5 - 36
Projects/Setup.dpr

@@ -179,29 +179,6 @@ begin
           AcceptedQueryEndSessionInProgress := False;
         Result := True;
       end;
-    WM_STYLECHANGING: begin
-        { On Delphi 2009, we must suppress some of the VCL's manipulation of
-          the application window styles in order to prevent the taskbar button
-          from re-appearing after SetTaskbarButtonVisibility(False) was used
-          to hide it.
-          - The VCL tries to clear WS_EX_TOOLWINDOW whenever a form handle is
-            created (see TCustomForm.CreateParams). Since
-            SetTaskbarButtonVisibility uses the WS_EX_TOOLWINDOW style
-            internally to hide the taskbar button, we can't allow that.
-          - The VCL tries to set WS_EX_APPWINDOW on the application window
-            after the main form is created (see ChangeAppWindow in Forms).
-            The WS_EX_APPWINDOW style forces the window to show a taskbar
-            button, overriding WS_EX_TOOLWINDOW, so don't allow that either.
-            (It appears to be redundant anyway.) }
-        if Integer(Message.WParam) = GWL_EXSTYLE then begin
-          { SetTaskbarButtonVisibility sets TaskbarButtonHidden }
-          if TaskbarButtonHidden then
-            PStyleStruct(Message.LParam).styleNew :=
-              PStyleStruct(Message.LParam).styleNew or WS_EX_TOOLWINDOW;
-          PStyleStruct(Message.LParam).styleNew :=
-            PStyleStruct(Message.LParam).styleNew and not WS_EX_APPWINDOW;
-        end;
-      end;
   end;
 end;
 
@@ -277,12 +254,6 @@ begin
 end;
 
 begin
-  { Delphi 2009 initially sets WS_EX_TOOLWINDOW on the application window.
-    That will prevent our ShowWindow(Application.Handle, SW_SHOW) calls from
-    actually displaying the taskbar button as intended, so clear it. }
-  SetWindowLong(Application.Handle, GWL_EXSTYLE,
-    GetWindowLong(Application.Handle, GWL_EXSTYLE) and not WS_EX_TOOLWINDOW);
-
   try
     SetErrorMode(SEM_FAILCRITICALERRORS);
     DisableWindowGhosting;
@@ -299,17 +270,15 @@ begin
     Note: There's no need to localize the following line since it's changed in
     InitializeSetup }
   Application.Title := 'Setup';
-  { On Delphi 3+, the application window by default isn't visible until a form
-    is shown. Force it visible like Delphi 2. Note that due to the way
-    TApplication.UpdateVisible is coded, this should be permanent; if a form
-    is shown and hidden, the application window should still be visible. }
-  ShowWindow(Application.Handle, SW_SHOW);
+  Application.ShowMainForm := False;
   Application.OnException := TMainForm.ShowException;
   try
     Application.Initialize;
+    Application.MainFormOnTaskBar := True;
     InitializeSetup;
-    Application.CreateForm(TMainForm, MainForm);
-  MainForm.InitializeWizard;
+    MainForm := TMainForm.Create(Application);
+    Application.CreateForm(TWizardForm, WizardForm);
+    MainForm.InitializeWizard;
   except
     { Halt on any exception }
     ShowExceptionMsg;

+ 0 - 10
Projects/Src/Compiler.ScriptClasses.pas

@@ -311,14 +311,6 @@ begin
   end;
 end;
 
-procedure RegisterMainForm_C(Cl: TPSPascalCompiler);
-begin
-  with CL.AddClassN(CL.FindClass('TSetupForm'), 'TMainForm') do
-  begin
-    RegisterMethod('procedure ShowAboutBox');
-  end;
-end;
-
 procedure RegisterWizardForm_C(Cl: TPSPascalCompiler);
 begin
   with Cl.AddClassN(Cl.FindClass('TSetupForm'), 'TWizardForm') do
@@ -675,7 +667,6 @@ begin
 
   RegisterUIStateForm_C(Cl);
   RegisterSetupForm_C(Cl);
-  RegisterMainForm_C(Cl);
   RegisterWizardForm_C(Cl);
   RegisterUninstallProgressForm_C(Cl);
 
@@ -694,7 +685,6 @@ begin
   RegisterHandCursor_C(Cl);
   
   AddImportedClassVariable(Cl, 'WizardForm', 'TWizardForm');
-  AddImportedClassVariable(Cl, 'MainForm', 'TMainForm');
   AddImportedClassVariable(Cl, 'UninstallProgressForm', 'TUninstallProgressForm');
 end;
 

+ 18 - 283
Projects/Src/Setup.MainForm.pas

@@ -13,28 +13,16 @@ interface
 
 uses
   Windows, Messages, SysUtils, Classes,
-  Shared.Struct, Setup.MainFunc, Setup.SetupForm, Shared.SetupSteps;
+  Shared.Struct, Setup.MainFunc, Shared.SetupSteps;
 
 type
-  TMainForm = class(TSetupForm)
-    procedure FormResize(Sender: TObject);
-    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
-    procedure FormPaint(Sender: TObject);
-    procedure FormKeyDown(Sender: TObject; var Key: Word;
-      Shift: TShiftState);
+  TMainForm = class(TComponent)
   private
-    IsMinimized, HideWizard: Boolean;
     class procedure AppOnGetActiveFormHandle(var AHandle: HWND);
-    function MainWindowHook(var Message: TMessage): Boolean;
-    procedure UpdateWizardFormVisibility(const IgnoreMinimizedState: Boolean = False);
-    procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND;
-    procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
-    procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE;
-    procedure WMShowWindow(var Message: TWMShowWindow); message WM_SHOWWINDOW;
   public
     CurStep: TSetupStep;
-    constructor Create(AOwner: TComponent); override;
     destructor Destroy; override;
+    procedure Close;
     procedure Finish(const FromPreparingPage: Boolean);
     procedure InitializeWizard;
     function Install: Boolean;
@@ -56,176 +44,12 @@ uses
   SetupLdrAndSetup.Messages, SetupLdrAndSetup.RedirFunc, Setup.Install,
   Setup.InstFunc, Setup.WizardForm, Setup.LoggingFunc, Shared.SetupTypes;
 
-{$R *.DFM}
-
-constructor TMainForm.Create(AOwner: TComponent);
-var
-  SystemMenu: HMenu;
-begin
-  inherited;
-
-  InitializeFont;
-
-  if shWindowVisible in SetupHeader.Options then begin
-    { Should the main window not be sizable? }
-    if not(shWindowShowCaption in SetupHeader.Options) then
-      BorderStyle := bsNone
-    else
-    if not(shWindowResizable in SetupHeader.Options) then
-      BorderStyle := bsSingle;
-
-    { Make the main window full-screen. If the window is resizable, limit it
-      to just the work area because full-screen resizable windows don't cover
-      over the taskbar. }
-    BoundsRect := GetRectOfPrimaryMonitor(BorderStyle = bsSizeable);
-    { Before maximizing the window, ensure Handle is created now so the correct
-      'restored' position is saved properly }
-    HandleNeeded;
-
-    { Maximize the window so that the taskbar is still accessible }
-    if shWindowStartMaximized in SetupHeader.Options then
-      WindowState := wsMaximized;
-  end
-  else begin
-    Application.ShowMainForm := False;
-  end;
-
-  if shDisableWelcomePage in SetupHeader.Options then
-    Caption := FmtSetupMessage1(msgSetupWindowTitle, ExpandedAppVerName)
-  else
-    Caption := FmtSetupMessage1(msgSetupWindowTitle, ExpandedAppName);
-
-  { Append the 'About Setup' item to the system menu }
-  SystemMenu := GetSystemMenu(Handle, False);
-  AppendMenu(SystemMenu, MF_SEPARATOR, 0, nil);
-  AppendMenu(SystemMenu, MF_STRING, 9999, PChar(SetupMessages[msgAboutSetupMenuItem]));
-
-  Application.HookMainWindow(MainWindowHook);
-
-  if Application.ShowMainForm then
-    { Show this form now, so that the focus stays on the wizard form that
-      InitializeWizard (called in the .dpr) shows }
-    Visible := True;
-end;
-
 destructor TMainForm.Destroy;
 begin
-  Application.UnhookMainWindow(MainWindowHook);
+  MainForm := nil;  { just to detect use-after-free }
   inherited;
 end;
 
-procedure TMainForm.WMSysCommand(var Message: TWMSysCommand);
-begin
-  if Message.CmdType = 9999 then
-    ShowAboutBox
-  else
-    inherited;
-end;
-
-procedure TMainForm.WMEraseBkgnd(var Message: TWMEraseBkgnd);
-begin
-  { Since the form paints its entire client area in FormPaint, there is
-    no need for the VCL to ever erase the client area with the brush color.
-    Doing so only slows it down, so this message handler disables that default
-    behavior. }
-  Message.Result := 0;
-end;
-
-procedure TMainForm.FormPaint(Sender: TObject);
-
-  function BlendRGB(const Color1, Color2: TColor; const Blend: Integer): TColor;
-  { Blends Color1 and Color2. Blend must be between 0 and 255; 0 = all Color1,
-    255 = all Color2. }
-  type
-    TColorBytes = array[0..3] of Byte;
-  var
-    I: Integer;
-  begin
-    Result := 0;
-    for I := 0 to 2 do
-      TColorBytes(Result)[I] := Integer(TColorBytes(Color1)[I] +
-        ((TColorBytes(Color2)[I] - TColorBytes(Color1)[I]) * Blend) div 255);
-  end;
-
-var
-  C1, C2: TColor;
-  CS: TPoint;
-  Z: Integer;
-  DrawTextFlags: UINT;
-  R, R2: TRect;
-begin
-  with Canvas do begin
-    { Draw the blue background }
-    if SetupHeader.BackColor = SetupHeader.BackColor2 then begin
-      Brush.Color := SetupHeader.BackColor;
-      FillRect(ClientRect);
-    end
-    else begin
-      C1 := ColorToRGB(SetupHeader.BackColor);
-      C2 := ColorToRGB(SetupHeader.BackColor2);
-      CS := ClientRect.BottomRight;
-      for Z := 0 to 255 do begin
-        Brush.Color := BlendRGB(C1, C2, Z);
-        if not(shBackColorHorizontal in SetupHeader.Options) then
-          FillRect(Rect(0, MulDiv(CS.Y, Z, 255), CS.X, MulDiv(CS.Y, Z+1, 255)))
-        else
-          FillRect(Rect(MulDiv(CS.X, Z, 255), 0, MulDiv(CS.X, Z+1, 255), CS.Y));
-      end;
-    end;
-
-    { Draw the application name and copyright }
-    SetBkMode(Handle, TRANSPARENT);
-
-    DrawTextFlags := DT_WORDBREAK or DT_NOPREFIX or DT_NOCLIP;
-    if RightToLeft then
-      DrawTextFlags := DrawTextFlags or (DT_RIGHT or DT_RTLREADING);
-    SetFontNameSize(Font, LangOptions.TitleFontName,
-      LangOptions.TitleFontSize, 'Arial', 29);
-    if IsMultiByteString(AnsiString(ExpandedAppName)) then
-      { Don't use italics on Japanese characters }
-      Font.Style := [fsBold]
-    else
-      Font.Style := [fsBold, fsItalic];
-    R := ClientRect;
-    InflateRect(R, -8, -8);
-    R2 := R;
-    if RightToLeft then
-      OffsetRect(R2, -4, 4)
-    else
-      OffsetRect(R2, 4, 4);
-    Font.Color := clBlack;
-    DrawText(Handle, PChar(ExpandedAppName), -1, R2, DrawTextFlags);
-    Font.Color := clWhite;
-    DrawText(Handle, PChar(ExpandedAppName), -1, R, DrawTextFlags);
-
-    DrawTextFlags := DrawTextFlags xor DT_RIGHT;
-    SetFontNameSize(Font, LangOptions.CopyrightFontName,
-      LangOptions.CopyrightFontSize, 'Arial', 8);
-    Font.Style := [];
-    R := ClientRect;
-    InflateRect(R, -6, -6);
-    R2 := R;
-    DrawText(Handle, PChar(ExpandedAppCopyright), -1, R2, DrawTextFlags or
-      DT_CALCRECT);
-    R.Top := R.Bottom - (R2.Bottom - R2.Top);
-    R2 := R;
-    if RightToLeft then
-      OffsetRect(R2, -1, 1)
-    else
-      OffsetRect(R2, 1, 1);
-    Font.Color := clBlack;
-    DrawText(Handle, PChar(ExpandedAppCopyright), -1, R2, DrawTextFlags);
-    Font.Color := clWhite;
-    DrawText(Handle, PChar(ExpandedAppCopyright), -1, R, DrawTextFlags);
-  end;
-end;
-
-procedure TMainForm.FormResize(Sender: TObject);
-begin
-  { Needs to redraw the background whenever the form is resized }
-  Repaint;
-end;
-
 procedure TMainForm.ShowAboutBox;
 var
   S: String;
@@ -284,7 +108,6 @@ end;
 
 procedure TMainForm.InitializeWizard;
 begin
-  WizardForm := TWizardForm.Create(Application);
   if CodeRunner <> nil then begin
     try
       CodeRunner.RunProcedures('InitializeWizard', [''], False);
@@ -293,11 +116,10 @@ begin
       raise;
     end;
   end;
-  WizardForm.FlipSizeAndCenterIfNeeded(shWindowVisible in SetupHeader.Options, MainForm, True);
+  WizardForm.FlipSizeAndCenterIfNeeded(False, nil, False);
   WizardForm.SetCurPage(wpWelcome);
   if InstallMode = imNormal then begin
     WizardForm.ClickToStartPage; { this won't go past wpReady  }
-    SetActiveWindow(Application.Handle);  { ensure taskbar button is selected }
     WizardForm.Show;
   end
   else
@@ -340,6 +162,7 @@ function TMainForm.Install: Boolean;
         not NeedsRestart;
       if CheckIfRestartNeeded then
         ChecksumBefore := MakePendingFileRenameOperationsChecksum;
+      var WizardWasHidden := False;
       WindowDisabler := nil;
       try
         for I := 0 to Entries[seRun].Count-1 do begin
@@ -365,15 +188,15 @@ function TMainForm.Install: Boolean;
               WizardForm.StatusLabel.Caption := SetupMessages[msgStatusRunProgram];
             WizardForm.StatusLabel.Update;
             if roHideWizard in RunEntry.Options then begin
-              if WizardForm.Visible and not HideWizard then begin
-                HideWizard := True;
-                UpdateWizardFormVisibility;
+              if WizardForm.Visible and not WizardWasHidden then begin
+                WizardWasHidden := True;
+                WizardForm.Hide;
               end;
             end
             else begin
-              if HideWizard then begin
-                HideWizard := False;
-                UpdateWizardFormVisibility;
+              if WizardWasHidden then begin
+                WizardWasHidden := False;
+                WizardForm.Show;
               end;
             end;
             DebugNotifyEntry(seRun, I);
@@ -383,10 +206,8 @@ function TMainForm.Install: Boolean;
           end;
         end;
       finally
-        if HideWizard then begin
-          HideWizard := False;
-          UpdateWizardFormVisibility;
-        end;
+        if WizardWasHidden then
+          WizardForm.Show;
         WindowDisabler.Free;
         if CheckIfRestartNeeded then begin
           ChecksumAfter := MakePendingFileRenameOperationsChecksum;
@@ -453,11 +274,8 @@ begin
       SaveInf(InitSaveInf);
 
     Application.Restore;
-    Update;
-    if InstallMode = imSilent then begin
-      SetActiveWindow(Application.Handle);  { ensure taskbar button is selected }
+    if InstallMode = imSilent then
       WizardForm.Show;
-    end;
     WizardForm.Update;
 
     SetStep(ssInstall, False);
@@ -514,10 +332,8 @@ begin
       end;
     end;
 
-    if InstallMode = imNormal then begin
+    if InstallMode = imNormal then
       Application.Restore;
-      Update;
-    end;
 
     Result := True;
   except
@@ -653,7 +469,7 @@ begin
   TerminateApp;
 end;
 
-procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
+procedure TMainForm.Close;
 
   function ConfirmCancel(const DefaultConfirm: Boolean): Boolean;
   var
@@ -666,9 +482,6 @@ procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
   end;
 
 begin
-  { Note: Setting CanClose to True causes Application.Terminate to be called;
-    we don't want that. }
-  CanClose := False;
   if Assigned(WizardForm) and WizardForm.HandleAllocated and
      IsWindowVisible(WizardForm.Handle) and IsWindowEnabled(WizardForm.Handle) and
      WizardForm.CancelButton.CanFocus then begin
@@ -689,84 +502,6 @@ begin
   end;
 end;
 
-procedure TMainForm.WMGetDlgCode(var Message: TWMGetDlgCode);
-begin
-  Message.Result := Message.Result or DLGC_WANTTAB;
-end;
-
-function EWP(Wnd: HWND; Param: LPARAM): BOOL; stdcall;
-begin
-  { Note: GetParent is not used here because the other windows are not
-    actually child windows since they don't have WS_CHILD set. }
-  if GetWindowLong(Wnd, GWL_HWNDPARENT) <> Param then
-    Result := True
-  else begin
-    Result := False;
-    BringWindowToTop(Wnd);
-  end;
-end;
-
-procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word;
-  Shift: TShiftState);
-begin
-  { If, for some reason, the user doesn't have a mouse and the main form was
-    activated, there would normally be no way to reactivate the child form.
-    But this reactivates the form if the user hits a key on the keyboard }
-  if not(ssAlt in Shift) then begin
-    Key := 0;
-    EnumThreadWindows(GetCurrentThreadId, @EWP, Handle);
-  end;
-end;
-
-procedure TMainForm.UpdateWizardFormVisibility(
-  const IgnoreMinimizedState: Boolean = False);
-var
-  ShouldShow: Boolean;
-begin
-  { Note: We don't adjust WizardForm.Visible because on Delphi 3+, if all forms
-    have Visible set to False, the application taskbar button disappears. }
-  if Assigned(WizardForm) and WizardForm.HandleAllocated then begin
-    ShouldShow := WizardForm.Showing and not HideWizard and
-      (IgnoreMinimizedState or not IsIconic(Application.Handle));
-    if (GetWindowLong(WizardForm.Handle, GWL_STYLE) and WS_VISIBLE <> 0) <> ShouldShow then begin
-      if ShouldShow then
-        ShowWindow(WizardForm.Handle, SW_SHOW)
-      else
-        ShowWindow(WizardForm.Handle, SW_HIDE);
-    end;
-  end;
-end;
-
-function TMainForm.MainWindowHook(var Message: TMessage): Boolean;
-var
-  IsIcon: Boolean;
-begin
-  Result := False;
-  case Message.Msg of
-    WM_WINDOWPOSCHANGED: begin
-        { When the application window is minimized or restored, also hide or
-          show WizardForm.
-          Note: MainForm is hidden/shown automatically because its owner
-          window is Application.Handle. }
-        IsIcon := IsIconic(Application.Handle);
-        if IsMinimized <> IsIcon then begin
-          IsMinimized := IsIcon;
-          UpdateWizardFormVisibility;
-        end;
-      end;
-  end;
-end;
-
-procedure TMainForm.WMShowWindow(var Message: TWMShowWindow);
-begin
-  inherited;
-  { When showing, ensure WizardForm is the active window, not MainForm }
-  if Message.Show and (GetActiveWindow = Handle) and
-     Assigned(WizardForm) and WizardForm.HandleAllocated and
-     IsWindowVisible(WizardForm.Handle) then
-    SetActiveWindow(WizardForm.Handle);
-end;
-
 procedure TMainForm.RestoreApp;
 { Restores the app if it is currently minimized, and tries to make its taskbar
   button blink (by attempting to bring it to the foreground, which Windows
@@ -786,7 +521,7 @@ begin
       implementation detail: Application.Restore could be a no-op if it finds
       the application window isn't minimized. (In fact, it used to be, until
       the Forms unit added that fake IsIconic function.) }
-    UpdateWizardFormVisibility(True);
+    //UpdateWizardFormVisibility(True);
     Application.Restore;
   end;
   Application.BringToFront;

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

@@ -153,7 +153,6 @@ var
   SetupExitCode: Integer;
   CreatedIcon: Boolean;
   RestartInitiatedByThisProcess, DownloadTemporaryFileOrExtract7ZipArchiveProcessMessages: Boolean;
-  TaskbarButtonHidden: Boolean;
   InstallModeRootKey: HKEY;
 
   CodeRunner: TScriptRunner;
@@ -212,7 +211,6 @@ procedure RemoveTempInstallDir;
 procedure SaveInf(const FileName: String);
 procedure SaveResourceToTempFile(const ResName, Filename: String);
 procedure SetActiveLanguage(const I: Integer);
-procedure SetTaskbarButtonVisibility(const AVisible: Boolean);
 procedure ShellExecuteAsOriginalUser(hWnd: HWND; Operation, FileName, Parameters, Directory: LPWSTR; ShowCmd: Integer); stdcall;
 function ShouldDisableFsRedirForFileEntry(const FileEntry: PSetupFileEntry): Boolean;
 function ShouldDisableFsRedirForRunEntry(const RunEntry: PSetupRunEntry): Boolean;
@@ -1179,12 +1177,6 @@ begin
     else
       Result := PSetupLanguageEntry(Entries[seLanguage][ActiveLanguage]).Name
   end
-  else if Cnst = 'hwnd' then begin
-    if Assigned(MainForm) then
-      Result := IntToStr(MainForm.Handle)
-    else
-      Result := '0';
-  end
   else if Cnst = 'wizardhwnd' then begin
     if Assigned(WizardForm) then
       Result := IntToStr(WizardForm.Handle)
@@ -2235,33 +2227,6 @@ begin
   SetActiveLanguage(I);
 end;
 
-procedure SetTaskbarButtonVisibility(const AVisible: Boolean);
-var
-  ExStyle: Longint;
-begin
-  { The taskbar button is hidden by setting the WS_EX_TOOLWINDOW style on the
-    application window. We can't simply hide the window because on D3+ the VCL
-    would just show it again in TApplication.UpdateVisible when the first form
-    is shown. }
-  TaskbarButtonHidden := not AVisible;  { see WM_STYLECHANGING hook in Setup.dpr }
-  if (GetWindowLong(Application.Handle, GWL_EXSTYLE) and WS_EX_TOOLWINDOW = 0) <> AVisible then begin
-    SetWindowPos(Application.Handle, 0, 0, 0, 0, 0, SWP_NOSIZE or
-      SWP_NOMOVE or SWP_NOZORDER or SWP_NOACTIVATE or SWP_HIDEWINDOW);
-    ExStyle := GetWindowLong(Application.Handle, GWL_EXSTYLE);
-    if AVisible then
-      ExStyle := ExStyle and not WS_EX_TOOLWINDOW
-    else
-      ExStyle := ExStyle or WS_EX_TOOLWINDOW;
-    SetWindowLong(Application.Handle, GWL_EXSTYLE, ExStyle);
-    if AVisible then
-      { Show and activate when becoming visible }
-      ShowWindow(Application.Handle, SW_SHOW)
-    else
-      SetWindowPos(Application.Handle, 0, 0, 0, 0, 0, SWP_NOSIZE or
-        SWP_NOMOVE or SWP_NOZORDER or SWP_NOACTIVATE or SWP_SHOWWINDOW);
-  end;
-end;
-
 procedure LogCompatibilityMode;
 var
   S: String;
@@ -2711,14 +2676,6 @@ var
       InstallMode := imVerySilent
     else if InitSilent then
       InstallMode := imSilent;
-
-    if InstallMode <> imNormal then begin
-      if InstallMode = imVerySilent then begin
-        Application.ShowMainForm := False;
-        SetTaskbarButtonVisibility(False);
-      end;
-      SetupHeader.Options := SetupHeader.Options - [shWindowVisible];
-    end;
   end;
 
   function RecurseExternalGetSizeOfFiles(const DisableFsRedir: Boolean;

+ 0 - 10
Projects/Src/Setup.ScriptClasses.pas

@@ -202,14 +202,6 @@ begin
   end;
 end;
 
-procedure RegisterMainForm_R(Cl: TPSRuntimeClassImporter);
-begin
-  with CL.Add(TMainForm) do
-  begin
-    RegisterMethod(@TMainForm.ShowAboutBox, 'ShowAboutBox');
-  end;
-end;
-
 procedure RegisterWizardForm_R(Cl: TPSRuntimeClassImporter);
 begin
   with Cl.Add(TWizardForm) do
@@ -444,7 +436,6 @@ begin
 
     RegisterUIStateForm_R(Cl);
     RegisterSetupForm_R(Cl);
-    RegisterMainForm_R(Cl);
     RegisterWizardForm_R(Cl);
     RegisterUninstallProgressForm_R(Cl);
 
@@ -474,7 +465,6 @@ end;
 procedure ScriptClassesLibraryUpdateVars(ScriptInterpreter: TIFPSExec);
 begin
   SetVariantToClass(ScriptInterpreter.GetVarNo(ScriptInterpreter.GetVar('WIZARDFORM')), WizardForm);
-  SetVariantToClass(ScriptInterpreter.GetVarNo(ScriptInterpreter.GetVar('MAINFORM')), MainForm);
   SetVariantToClass(ScriptInterpreter.GetVarNo(ScriptInterpreter.GetVar('UNINSTALLPROGRESSFORM')), UninstallProgressForm);
 end;
 

+ 0 - 4
Projects/Src/Setup.ScriptFunc.pas

@@ -1175,10 +1175,6 @@ var
     begin
       Stack.SetBool(PStart, CodeRegisterExtraCloseApplicationsResource(Stack.GetBool(PStart-1), Stack.GetString(PStart-2)));
     end);
-    RegisterScriptFunc('GETMAINFORM', procedure(const Caller: TPSExec; const OrgName: AnsiString; const Stack: TPSStack; const PStart: Cardinal)
-    begin
-      Stack.SetClass(PStart, GetMainForm);
-    end);
     RegisterScriptFunc('GETWIZARDFORM', procedure(const Caller: TPSExec; const OrgName: AnsiString; const Stack: TPSStack; const PStart: Cardinal)
     begin
       Stack.SetClass(PStart, GetWizardForm);

+ 1 - 1
Projects/Src/Setup.SelectLanguageForm.pas

@@ -48,7 +48,7 @@ var
   I, J: Integer;
   LangEntry: PSetupLanguageEntry;
 begin
-  LangForm := TSelectLanguageForm.Create(Application);
+  Application.CreateForm(TSelectLanguageForm, LangForm);
   try
     for I := 0 to Entries[seLanguage].Count-1 do begin
       LangEntry := Entries[seLanguage][I];

+ 2 - 7
Projects/Src/Setup.Uninstall.pas

@@ -91,7 +91,7 @@ end;
 
 procedure InitializeUninstallProgressForm;
 begin
-  UninstallProgressForm := TUninstallProgressForm.Create(nil);
+  Application.CreateForm(TUninstallProgressForm, UninstallProgressForm);
   UninstallProgressForm.Initialize(Title, UninstLog.AppName, ufModernStyle in UninstLog.Flags);
   if CodeRunner <> nil then begin
     try
@@ -485,9 +485,6 @@ var
   Res, RemovedAll, UninstallNeedsRestart: Boolean;
   StartTime: DWORD;
 begin
-  if VerySilent then
-    SetTaskbarButtonVisibility(False);
-
   RestartSystem := False;
   AllowUninstallerShutdown := True;
 
@@ -758,9 +755,7 @@ var
 begin
   { Set default title; it's set again below after the messages are read }
   Application.Title := 'Uninstall';
-  { This is needed for D3+: Must force the application window visible since
-    we aren't displaying any forms }
-  ShowWindow(Application.Handle, SW_SHOW);
+  Application.MainFormOnTaskBar := True;
 
   try
     InitializeCommonVars;

+ 2 - 18
Projects/Src/Setup.WizardForm.pas

@@ -211,8 +211,6 @@ type
     procedure UpdatePage(const PageID: Integer);
     procedure UpdateSelectTasksPage;
     procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND;
-  protected
-    procedure CreateParams(var Params: TCreateParams); override;
   public
     { Public declarations }
     PrepareToInstallFailureMessage: String;
@@ -1347,14 +1345,6 @@ begin
   inherited;
 end;
 
-procedure TWizardForm.CreateParams(var Params: TCreateParams);
-begin
-  inherited;
-  { Ensure the form is *always* on top of MainForm by making MainForm
-    the "parent" of the form. }
-  Params.WndParent := MainForm.Handle;
-end;
-
 function TWizardForm.PageIndexFromID(const ID: Integer): Integer;
 { Given a page ID, returns the index of the page in FPageList. An exception is
   raised if a page with the specified ID is not found. }
@@ -1865,10 +1855,8 @@ begin
     BackButton.Visible := False;
     NextButton.Visible := False;
     CancelButton.Enabled := False;
-    if InstallMode = imSilent then begin
-      SetActiveWindow(Application.Handle);  { ensure taskbar button is selected }
+    if InstallMode = imSilent then
       WizardForm.Show;
-    end;
     WizardForm.Update;
     try
       DownloadTemporaryFileOrExtract7ZipArchiveProcessMessages := True;
@@ -2559,10 +2547,8 @@ begin
               SetCurPage(wpPreparing); { controls are already hidden by PrepareToInstall }
               BackButton.Visible := False;
               NextButton.Visible := False;
-              if InstallMode = imSilent then begin
-                SetActiveWindow(Application.Handle);  { ensure taskbar button is selected }
+              if InstallMode = imSilent then
                 WizardForm.Show;
-              end;
               try
                 WizardForm.Update;
                 RmFoundApplications := QueryRestartManager(WizardComponents, WizardTasks) <> '';
@@ -3044,9 +3030,7 @@ begin
           The taskbar button will be hidden at this point on very silent
           installs (see SetupInstallMode); re-show it. }
         Log('Failed to proceed to next wizard page; showing wizard.');
-        SetTaskbarButtonVisibility(True);
         Application.Restore;
-        SetActiveWindow(Application.Handle);  { ensure taskbar button is selected }
         WizardForm.Show;
         Break;
       end;

+ 0 - 2
Projects/Src/Shared.ScriptFunc.pas

@@ -400,8 +400,6 @@ initialization
     'function CustomMessage(const MsgName: String): String;',
     'function RmSessionStarted: Boolean;',
     'function RegisterExtraCloseApplicationsResource(const DisableFsRedir: Boolean; const AFilename: String): Boolean;',
-    { Actually access MainForm.pas }
-    'function GetMainForm: TMainForm;',
     { Actually access WizardForm.pas }
     'function GetWizardForm: TWizardForm;',
     'function WizardIsComponentSelected(const Components: String): Boolean;',