Prechádzať zdrojové kódy

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 mesiacov pred
rodič
commit
9d52a24040

+ 5 - 36
Projects/Setup.dpr

@@ -179,29 +179,6 @@ begin
           AcceptedQueryEndSessionInProgress := False;
           AcceptedQueryEndSessionInProgress := False;
         Result := True;
         Result := True;
       end;
       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;
 end;
 end;
 
 
@@ -277,12 +254,6 @@ begin
 end;
 end;
 
 
 begin
 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
   try
     SetErrorMode(SEM_FAILCRITICALERRORS);
     SetErrorMode(SEM_FAILCRITICALERRORS);
     DisableWindowGhosting;
     DisableWindowGhosting;
@@ -299,17 +270,15 @@ begin
     Note: There's no need to localize the following line since it's changed in
     Note: There's no need to localize the following line since it's changed in
     InitializeSetup }
     InitializeSetup }
   Application.Title := 'Setup';
   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;
   Application.OnException := TMainForm.ShowException;
   try
   try
     Application.Initialize;
     Application.Initialize;
+    Application.MainFormOnTaskBar := True;
     InitializeSetup;
     InitializeSetup;
-    Application.CreateForm(TMainForm, MainForm);
-  MainForm.InitializeWizard;
+    MainForm := TMainForm.Create(Application);
+    Application.CreateForm(TWizardForm, WizardForm);
+    MainForm.InitializeWizard;
   except
   except
     { Halt on any exception }
     { Halt on any exception }
     ShowExceptionMsg;
     ShowExceptionMsg;

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

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

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

@@ -13,28 +13,16 @@ interface
 
 
 uses
 uses
   Windows, Messages, SysUtils, Classes,
   Windows, Messages, SysUtils, Classes,
-  Shared.Struct, Setup.MainFunc, Setup.SetupForm, Shared.SetupSteps;
+  Shared.Struct, Setup.MainFunc, Shared.SetupSteps;
 
 
 type
 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
   private
-    IsMinimized, HideWizard: Boolean;
     class procedure AppOnGetActiveFormHandle(var AHandle: HWND);
     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
   public
     CurStep: TSetupStep;
     CurStep: TSetupStep;
-    constructor Create(AOwner: TComponent); override;
     destructor Destroy; override;
     destructor Destroy; override;
+    procedure Close;
     procedure Finish(const FromPreparingPage: Boolean);
     procedure Finish(const FromPreparingPage: Boolean);
     procedure InitializeWizard;
     procedure InitializeWizard;
     function Install: Boolean;
     function Install: Boolean;
@@ -56,176 +44,12 @@ uses
   SetupLdrAndSetup.Messages, SetupLdrAndSetup.RedirFunc, Setup.Install,
   SetupLdrAndSetup.Messages, SetupLdrAndSetup.RedirFunc, Setup.Install,
   Setup.InstFunc, Setup.WizardForm, Setup.LoggingFunc, Shared.SetupTypes;
   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;
 destructor TMainForm.Destroy;
 begin
 begin
-  Application.UnhookMainWindow(MainWindowHook);
+  MainForm := nil;  { just to detect use-after-free }
   inherited;
   inherited;
 end;
 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;
 procedure TMainForm.ShowAboutBox;
 var
 var
   S: String;
   S: String;
@@ -284,7 +108,6 @@ end;
 
 
 procedure TMainForm.InitializeWizard;
 procedure TMainForm.InitializeWizard;
 begin
 begin
-  WizardForm := TWizardForm.Create(Application);
   if CodeRunner <> nil then begin
   if CodeRunner <> nil then begin
     try
     try
       CodeRunner.RunProcedures('InitializeWizard', [''], False);
       CodeRunner.RunProcedures('InitializeWizard', [''], False);
@@ -293,11 +116,10 @@ begin
       raise;
       raise;
     end;
     end;
   end;
   end;
-  WizardForm.FlipSizeAndCenterIfNeeded(shWindowVisible in SetupHeader.Options, MainForm, True);
+  WizardForm.FlipSizeAndCenterIfNeeded(False, nil, False);
   WizardForm.SetCurPage(wpWelcome);
   WizardForm.SetCurPage(wpWelcome);
   if InstallMode = imNormal then begin
   if InstallMode = imNormal then begin
     WizardForm.ClickToStartPage; { this won't go past wpReady  }
     WizardForm.ClickToStartPage; { this won't go past wpReady  }
-    SetActiveWindow(Application.Handle);  { ensure taskbar button is selected }
     WizardForm.Show;
     WizardForm.Show;
   end
   end
   else
   else
@@ -340,6 +162,7 @@ function TMainForm.Install: Boolean;
         not NeedsRestart;
         not NeedsRestart;
       if CheckIfRestartNeeded then
       if CheckIfRestartNeeded then
         ChecksumBefore := MakePendingFileRenameOperationsChecksum;
         ChecksumBefore := MakePendingFileRenameOperationsChecksum;
+      var WizardWasHidden := False;
       WindowDisabler := nil;
       WindowDisabler := nil;
       try
       try
         for I := 0 to Entries[seRun].Count-1 do begin
         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.Caption := SetupMessages[msgStatusRunProgram];
             WizardForm.StatusLabel.Update;
             WizardForm.StatusLabel.Update;
             if roHideWizard in RunEntry.Options then begin
             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;
             end
             end
             else begin
             else begin
-              if HideWizard then begin
-                HideWizard := False;
-                UpdateWizardFormVisibility;
+              if WizardWasHidden then begin
+                WizardWasHidden := False;
+                WizardForm.Show;
               end;
               end;
             end;
             end;
             DebugNotifyEntry(seRun, I);
             DebugNotifyEntry(seRun, I);
@@ -383,10 +206,8 @@ function TMainForm.Install: Boolean;
           end;
           end;
         end;
         end;
       finally
       finally
-        if HideWizard then begin
-          HideWizard := False;
-          UpdateWizardFormVisibility;
-        end;
+        if WizardWasHidden then
+          WizardForm.Show;
         WindowDisabler.Free;
         WindowDisabler.Free;
         if CheckIfRestartNeeded then begin
         if CheckIfRestartNeeded then begin
           ChecksumAfter := MakePendingFileRenameOperationsChecksum;
           ChecksumAfter := MakePendingFileRenameOperationsChecksum;
@@ -453,11 +274,8 @@ begin
       SaveInf(InitSaveInf);
       SaveInf(InitSaveInf);
 
 
     Application.Restore;
     Application.Restore;
-    Update;
-    if InstallMode = imSilent then begin
-      SetActiveWindow(Application.Handle);  { ensure taskbar button is selected }
+    if InstallMode = imSilent then
       WizardForm.Show;
       WizardForm.Show;
-    end;
     WizardForm.Update;
     WizardForm.Update;
 
 
     SetStep(ssInstall, False);
     SetStep(ssInstall, False);
@@ -514,10 +332,8 @@ begin
       end;
       end;
     end;
     end;
 
 
-    if InstallMode = imNormal then begin
+    if InstallMode = imNormal then
       Application.Restore;
       Application.Restore;
-      Update;
-    end;
 
 
     Result := True;
     Result := True;
   except
   except
@@ -653,7 +469,7 @@ begin
   TerminateApp;
   TerminateApp;
 end;
 end;
 
 
-procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
+procedure TMainForm.Close;
 
 
   function ConfirmCancel(const DefaultConfirm: Boolean): Boolean;
   function ConfirmCancel(const DefaultConfirm: Boolean): Boolean;
   var
   var
@@ -666,9 +482,6 @@ procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
   end;
   end;
 
 
 begin
 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
   if Assigned(WizardForm) and WizardForm.HandleAllocated and
      IsWindowVisible(WizardForm.Handle) and IsWindowEnabled(WizardForm.Handle) and
      IsWindowVisible(WizardForm.Handle) and IsWindowEnabled(WizardForm.Handle) and
      WizardForm.CancelButton.CanFocus then begin
      WizardForm.CancelButton.CanFocus then begin
@@ -689,84 +502,6 @@ begin
   end;
   end;
 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;
 procedure TMainForm.RestoreApp;
 { Restores the app if it is currently minimized, and tries to make its taskbar
 { 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
   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
       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 application window isn't minimized. (In fact, it used to be, until
       the Forms unit added that fake IsIconic function.) }
       the Forms unit added that fake IsIconic function.) }
-    UpdateWizardFormVisibility(True);
+    //UpdateWizardFormVisibility(True);
     Application.Restore;
     Application.Restore;
   end;
   end;
   Application.BringToFront;
   Application.BringToFront;

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

@@ -153,7 +153,6 @@ var
   SetupExitCode: Integer;
   SetupExitCode: Integer;
   CreatedIcon: Boolean;
   CreatedIcon: Boolean;
   RestartInitiatedByThisProcess, DownloadTemporaryFileOrExtract7ZipArchiveProcessMessages: Boolean;
   RestartInitiatedByThisProcess, DownloadTemporaryFileOrExtract7ZipArchiveProcessMessages: Boolean;
-  TaskbarButtonHidden: Boolean;
   InstallModeRootKey: HKEY;
   InstallModeRootKey: HKEY;
 
 
   CodeRunner: TScriptRunner;
   CodeRunner: TScriptRunner;
@@ -212,7 +211,6 @@ procedure RemoveTempInstallDir;
 procedure SaveInf(const FileName: String);
 procedure SaveInf(const FileName: String);
 procedure SaveResourceToTempFile(const ResName, Filename: String);
 procedure SaveResourceToTempFile(const ResName, Filename: String);
 procedure SetActiveLanguage(const I: Integer);
 procedure SetActiveLanguage(const I: Integer);
-procedure SetTaskbarButtonVisibility(const AVisible: Boolean);
 procedure ShellExecuteAsOriginalUser(hWnd: HWND; Operation, FileName, Parameters, Directory: LPWSTR; ShowCmd: Integer); stdcall;
 procedure ShellExecuteAsOriginalUser(hWnd: HWND; Operation, FileName, Parameters, Directory: LPWSTR; ShowCmd: Integer); stdcall;
 function ShouldDisableFsRedirForFileEntry(const FileEntry: PSetupFileEntry): Boolean;
 function ShouldDisableFsRedirForFileEntry(const FileEntry: PSetupFileEntry): Boolean;
 function ShouldDisableFsRedirForRunEntry(const RunEntry: PSetupRunEntry): Boolean;
 function ShouldDisableFsRedirForRunEntry(const RunEntry: PSetupRunEntry): Boolean;
@@ -1179,12 +1177,6 @@ begin
     else
     else
       Result := PSetupLanguageEntry(Entries[seLanguage][ActiveLanguage]).Name
       Result := PSetupLanguageEntry(Entries[seLanguage][ActiveLanguage]).Name
   end
   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
   else if Cnst = 'wizardhwnd' then begin
     if Assigned(WizardForm) then
     if Assigned(WizardForm) then
       Result := IntToStr(WizardForm.Handle)
       Result := IntToStr(WizardForm.Handle)
@@ -2235,33 +2227,6 @@ begin
   SetActiveLanguage(I);
   SetActiveLanguage(I);
 end;
 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;
 procedure LogCompatibilityMode;
 var
 var
   S: String;
   S: String;
@@ -2711,14 +2676,6 @@ var
       InstallMode := imVerySilent
       InstallMode := imVerySilent
     else if InitSilent then
     else if InitSilent then
       InstallMode := imSilent;
       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;
   end;
 
 
   function RecurseExternalGetSizeOfFiles(const DisableFsRedir: Boolean;
   function RecurseExternalGetSizeOfFiles(const DisableFsRedir: Boolean;

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

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

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

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

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

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

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

@@ -91,7 +91,7 @@ end;
 
 
 procedure InitializeUninstallProgressForm;
 procedure InitializeUninstallProgressForm;
 begin
 begin
-  UninstallProgressForm := TUninstallProgressForm.Create(nil);
+  Application.CreateForm(TUninstallProgressForm, UninstallProgressForm);
   UninstallProgressForm.Initialize(Title, UninstLog.AppName, ufModernStyle in UninstLog.Flags);
   UninstallProgressForm.Initialize(Title, UninstLog.AppName, ufModernStyle in UninstLog.Flags);
   if CodeRunner <> nil then begin
   if CodeRunner <> nil then begin
     try
     try
@@ -485,9 +485,6 @@ var
   Res, RemovedAll, UninstallNeedsRestart: Boolean;
   Res, RemovedAll, UninstallNeedsRestart: Boolean;
   StartTime: DWORD;
   StartTime: DWORD;
 begin
 begin
-  if VerySilent then
-    SetTaskbarButtonVisibility(False);
-
   RestartSystem := False;
   RestartSystem := False;
   AllowUninstallerShutdown := True;
   AllowUninstallerShutdown := True;
 
 
@@ -758,9 +755,7 @@ var
 begin
 begin
   { Set default title; it's set again below after the messages are read }
   { Set default title; it's set again below after the messages are read }
   Application.Title := 'Uninstall';
   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
   try
     InitializeCommonVars;
     InitializeCommonVars;

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

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

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

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