Kaynağa Gözat

Added a RestartManager UI to wpPreparing.

Martijn Laan 13 yıl önce
ebeveyn
işleme
0fb771e945
4 değiştirilmiş dosya ile 60 ekleme ve 8 silme
  1. 1 1
      Projects/Main.pas
  2. BIN
      Projects/Wizard.dfm
  3. 16 2
      Projects/Wizard.dfm.txt
  4. 43 5
      Projects/Wizard.pas

+ 1 - 1
Projects/Main.pas

@@ -3982,7 +3982,7 @@ begin
      WizardForm.CancelButton.CanFocus then begin
     case CurStep of
       ssPreInstall:
-        if ConfirmCancel(WizardForm.CurPageID <> wpPreparing) then begin
+        if ConfirmCancel((WizardForm.CurPageID <> wpPreparing) or (WizardForm.PrepareToInstallFailureMessage = '')) then begin
           if WizardForm.CurPageID = wpPreparing then
             SetupExitCode := ecPrepareToInstallFailed
           else

BIN
Projects/Wizard.dfm


+ 16 - 2
Projects/Wizard.dfm.txt

@@ -500,7 +500,7 @@ object WizardForm: TWizardForm
             Height = 17
             Caption = '*'
             Checked = True
-            TabOrder = 1
+            TabOrder = 2
             TabStop = True
             Visible = False
           end
@@ -510,9 +510,23 @@ object WizardForm: TWizardForm
             Width = 301
             Height = 17
             Caption = '*'
-            TabOrder = 2
+            TabOrder = 3
             Visible = False
           end
+          object PreparingMemo: TNewMemo
+            Left = 24
+            Top = 88
+            Width = 393
+            Height = 145
+            Color = clBtnFace
+            Lines.Strings = (
+              'PreparingMemo')
+            ReadOnly = True
+            ScrollBars = ssBoth
+            TabOrder = 1
+            WantReturns = False
+            WordWrap = False
+          end
         end
         object InstallingPage: TNewNotebookPage
           object FilenameLabel: TNewStaticText

+ 43 - 5
Projects/Wizard.pas

@@ -158,6 +158,7 @@ type
     SelectStartMenuFolderBrowseLabel: TNewStaticText;
     PreparingYesRadio: TNewRadioButton;
     PreparingNoRadio: TNewRadioButton;
+    PreparingMemo: TNewMemo;
     procedure NextButtonClick(Sender: TObject);
     procedure BackButtonClick(Sender: TObject);
     procedure CancelButtonClick(Sender: TObject);
@@ -193,6 +194,7 @@ type
     procedure FindPreviousData;
     function GetPreviousPageID: Integer;
     function PrepareToInstall: String;
+    function QueryRestartManager: String;
     procedure RegisterExistingPage(const ID: Integer;
      const AOuterNotebookPage, AInnerNotebookPage: TNewNotebookPage;
      const ACaption, ADescription: String);
@@ -903,8 +905,6 @@ begin
   { Initialize wpPreparing page }
   RegisterExistingPage(wpPreparing, InnerPage, PreparingPage,
     SetupMessages[msgWizardPreparing], ExpandSetupMessage(msgPreparingDesc));
-  PreparingYesRadio.Caption := SetupMessages[msgYesRadio];
-  PreparingNoRadio.Caption := SetupMessages[msgNoRadio];
 
   { Initialize wpInstalling page }
   RegisterExistingPage(wpInstalling, InnerPage, InstallingPage,
@@ -1616,6 +1616,7 @@ begin
   PreparingLabel.Visible := False;
   PreparingYesRadio.Visible := False;
   PreparingNoRadio.Visible := False;
+  PreparingMemo.Visible := False;
   if PreviousInstallNotCompleted then begin
     Result := ExpandSetupMessage(msgPreviousInstallNotCompleted);
     PrepareToInstallNeedsRestart := True;
@@ -1644,13 +1645,43 @@ begin
     if PrepareToInstallNeedsRestart then begin
       Y := PreparingLabel.Top + PreparingLabel.Height;
       PreparingYesRadio.Top := Y;
+      PreparingYesRadio.Caption := SetupMessages[msgYesRadio];
       PreparingYesRadio.Visible := True;
       PreparingNoRadio.Top := Y + ScalePixelsY(22);
+      PreparingNoRadio.Caption := SetupMessages[msgNoRadio];
       PreparingNoRadio.Visible := True;
     end;
   end;
 end;
 
+function TWizardForm.QueryRestartManager: String;
+var
+  Y: Integer;
+begin
+  Result := 'Windows Verkenner'#13#10'Notepad';
+
+  if Result <> '' then begin
+    PreparingLabel.Caption := 'The following applications are using files that need to be updated by this setup. You can let Setup Wizard close them and attempt to restart them or reboot the machine later.';
+    Y := PreparingLabel.Top + PreparingLabel.Height + ScalePixelsY(12);
+    PreparingMemo.Top := Y;
+    IncTopDecHeight(PreparingMemo, AdjustLabelHeight(PreparingLabel));
+    AdjustLabelHeight(PreparingLabel);
+    PreparingErrorBitmapImage.Visible := True;
+    PreparingLabel.Visible := True;
+    PreparingMemo.Text := Result;
+    PreparingMemo.Visible := True;
+    Y := PreparingMemo.Top + PreparingMemo.Height + ScalePixelsY(12);
+    PreparingYesRadio.Top := Y;
+    PreparingYesRadio.Caption := 'Close the applications and attempt to restart them.';
+    PreparingYesRadio.Visible := True;
+    PreparingNoRadio.Top := Y + ScalePixelsY(22);
+    PreparingNoRadio.Caption := 'Do not close the applications. A reboot will be required.';
+    PreparingNoRadio.Visible := True;
+
+    StringChange(Result, #13#10, ', ');
+  end;
+end;
+
 procedure TWizardForm.UpdatePage(const PageID: Integer);
 
   procedure ReadyMemoAppend(const Lines: String);
@@ -1771,7 +1802,7 @@ var
 begin
   if CurPageID = wpReady then
     NewActiveControl := NextButton
-  else if (CurPageID = wpPreparing) and not PrepareToInstallNeedsRestart then
+  else if (CurPageID = wpPreparing) and (PrepareToInstallFailureMessage <> '') and not PrepareToInstallNeedsRestart then
     NewActiveControl := CancelButton
   else
     NewActiveControl := FindNextControl(nil, True, True, False);
@@ -1826,7 +1857,7 @@ begin
     NextButton.Visible := CurPageID <> wpInstalling;
     case CurPageID of
       wpLicense: NextButton.Enabled := LicenseAcceptedRadio.Checked;
-      wpPreparing: NextButton.Enabled := PrepareToInstallNeedsRestart;
+      wpPreparing: NextButton.Enabled := (PrepareToInstallFailureMessage = '') or PrepareToInstallNeedsRestart;
     else
       NextButton.Enabled := True;
     end;
@@ -2085,6 +2116,7 @@ var
   PageIndex: Integer;
   Continue: Boolean;
   NewPageID: Integer;
+  RestartManagerResult: String;
 label Again;
 begin
   if CurPageID = wpInstalling then
@@ -2146,6 +2178,12 @@ begin
             LogFmt('PrepareToInstall failed: %s', [PrepareToInstallFailureMessage]);
             LogFmt('Need to restart Windows? %s', [SYesNo[PrepareToInstallNeedsRestart]]);
             Break;  { stop on the page }
+          end else begin
+            RestartManagerResult := QueryRestartManager;
+            if RestartManagerResult <> '' then begin
+              LogFmt('RestartManager returned items: %s', [RestartManagerResult]);
+              Break;  { stop on the page }
+            end;
           end;
         end;
       wpInstalling: begin
@@ -2565,7 +2603,7 @@ var
   BeforeID: Integer;
 begin
   while True do begin
-    if (CurPageID = wpPreparing) and not (PrepareToInstallNeedsRestart and not InitNoRestart) then begin
+    if (CurPageID = wpPreparing) and (PrepareToInstallFailureMessage <> '') and not (PrepareToInstallNeedsRestart and not InitNoRestart) then begin
       { Special handling needed for wpPreparing since it displays its error
         message inline on the wizard. Since the wizard isn't currently visible,
         we have to display the messsage in a message box if it won't be displayed