浏览代码

Added a RestartManager UI to wpPreparing.

Martijn Laan 13 年之前
父节点
当前提交
0fb771e945
共有 4 个文件被更改,包括 60 次插入8 次删除
  1. 1 1
      Projects/Main.pas
  2. 二进制
      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
      WizardForm.CancelButton.CanFocus then begin
     case CurStep of
     case CurStep of
       ssPreInstall:
       ssPreInstall:
-        if ConfirmCancel(WizardForm.CurPageID <> wpPreparing) then begin
+        if ConfirmCancel((WizardForm.CurPageID <> wpPreparing) or (WizardForm.PrepareToInstallFailureMessage = '')) then begin
           if WizardForm.CurPageID = wpPreparing then
           if WizardForm.CurPageID = wpPreparing then
             SetupExitCode := ecPrepareToInstallFailed
             SetupExitCode := ecPrepareToInstallFailed
           else
           else

二进制
Projects/Wizard.dfm


+ 16 - 2
Projects/Wizard.dfm.txt

@@ -500,7 +500,7 @@ object WizardForm: TWizardForm
             Height = 17
             Height = 17
             Caption = '*'
             Caption = '*'
             Checked = True
             Checked = True
-            TabOrder = 1
+            TabOrder = 2
             TabStop = True
             TabStop = True
             Visible = False
             Visible = False
           end
           end
@@ -510,9 +510,23 @@ object WizardForm: TWizardForm
             Width = 301
             Width = 301
             Height = 17
             Height = 17
             Caption = '*'
             Caption = '*'
-            TabOrder = 2
+            TabOrder = 3
             Visible = False
             Visible = False
           end
           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
         end
         object InstallingPage: TNewNotebookPage
         object InstallingPage: TNewNotebookPage
           object FilenameLabel: TNewStaticText
           object FilenameLabel: TNewStaticText

+ 43 - 5
Projects/Wizard.pas

@@ -158,6 +158,7 @@ type
     SelectStartMenuFolderBrowseLabel: TNewStaticText;
     SelectStartMenuFolderBrowseLabel: TNewStaticText;
     PreparingYesRadio: TNewRadioButton;
     PreparingYesRadio: TNewRadioButton;
     PreparingNoRadio: TNewRadioButton;
     PreparingNoRadio: TNewRadioButton;
+    PreparingMemo: TNewMemo;
     procedure NextButtonClick(Sender: TObject);
     procedure NextButtonClick(Sender: TObject);
     procedure BackButtonClick(Sender: TObject);
     procedure BackButtonClick(Sender: TObject);
     procedure CancelButtonClick(Sender: TObject);
     procedure CancelButtonClick(Sender: TObject);
@@ -193,6 +194,7 @@ type
     procedure FindPreviousData;
     procedure FindPreviousData;
     function GetPreviousPageID: Integer;
     function GetPreviousPageID: Integer;
     function PrepareToInstall: String;
     function PrepareToInstall: String;
+    function QueryRestartManager: String;
     procedure RegisterExistingPage(const ID: Integer;
     procedure RegisterExistingPage(const ID: Integer;
      const AOuterNotebookPage, AInnerNotebookPage: TNewNotebookPage;
      const AOuterNotebookPage, AInnerNotebookPage: TNewNotebookPage;
      const ACaption, ADescription: String);
      const ACaption, ADescription: String);
@@ -903,8 +905,6 @@ begin
   { Initialize wpPreparing page }
   { Initialize wpPreparing page }
   RegisterExistingPage(wpPreparing, InnerPage, PreparingPage,
   RegisterExistingPage(wpPreparing, InnerPage, PreparingPage,
     SetupMessages[msgWizardPreparing], ExpandSetupMessage(msgPreparingDesc));
     SetupMessages[msgWizardPreparing], ExpandSetupMessage(msgPreparingDesc));
-  PreparingYesRadio.Caption := SetupMessages[msgYesRadio];
-  PreparingNoRadio.Caption := SetupMessages[msgNoRadio];
 
 
   { Initialize wpInstalling page }
   { Initialize wpInstalling page }
   RegisterExistingPage(wpInstalling, InnerPage, InstallingPage,
   RegisterExistingPage(wpInstalling, InnerPage, InstallingPage,
@@ -1616,6 +1616,7 @@ begin
   PreparingLabel.Visible := False;
   PreparingLabel.Visible := False;
   PreparingYesRadio.Visible := False;
   PreparingYesRadio.Visible := False;
   PreparingNoRadio.Visible := False;
   PreparingNoRadio.Visible := False;
+  PreparingMemo.Visible := False;
   if PreviousInstallNotCompleted then begin
   if PreviousInstallNotCompleted then begin
     Result := ExpandSetupMessage(msgPreviousInstallNotCompleted);
     Result := ExpandSetupMessage(msgPreviousInstallNotCompleted);
     PrepareToInstallNeedsRestart := True;
     PrepareToInstallNeedsRestart := True;
@@ -1644,13 +1645,43 @@ begin
     if PrepareToInstallNeedsRestart then begin
     if PrepareToInstallNeedsRestart then begin
       Y := PreparingLabel.Top + PreparingLabel.Height;
       Y := PreparingLabel.Top + PreparingLabel.Height;
       PreparingYesRadio.Top := Y;
       PreparingYesRadio.Top := Y;
+      PreparingYesRadio.Caption := SetupMessages[msgYesRadio];
       PreparingYesRadio.Visible := True;
       PreparingYesRadio.Visible := True;
       PreparingNoRadio.Top := Y + ScalePixelsY(22);
       PreparingNoRadio.Top := Y + ScalePixelsY(22);
+      PreparingNoRadio.Caption := SetupMessages[msgNoRadio];
       PreparingNoRadio.Visible := True;
       PreparingNoRadio.Visible := True;
     end;
     end;
   end;
   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 TWizardForm.UpdatePage(const PageID: Integer);
 
 
   procedure ReadyMemoAppend(const Lines: String);
   procedure ReadyMemoAppend(const Lines: String);
@@ -1771,7 +1802,7 @@ var
 begin
 begin
   if CurPageID = wpReady then
   if CurPageID = wpReady then
     NewActiveControl := NextButton
     NewActiveControl := NextButton
-  else if (CurPageID = wpPreparing) and not PrepareToInstallNeedsRestart then
+  else if (CurPageID = wpPreparing) and (PrepareToInstallFailureMessage <> '') and not PrepareToInstallNeedsRestart then
     NewActiveControl := CancelButton
     NewActiveControl := CancelButton
   else
   else
     NewActiveControl := FindNextControl(nil, True, True, False);
     NewActiveControl := FindNextControl(nil, True, True, False);
@@ -1826,7 +1857,7 @@ begin
     NextButton.Visible := CurPageID <> wpInstalling;
     NextButton.Visible := CurPageID <> wpInstalling;
     case CurPageID of
     case CurPageID of
       wpLicense: NextButton.Enabled := LicenseAcceptedRadio.Checked;
       wpLicense: NextButton.Enabled := LicenseAcceptedRadio.Checked;
-      wpPreparing: NextButton.Enabled := PrepareToInstallNeedsRestart;
+      wpPreparing: NextButton.Enabled := (PrepareToInstallFailureMessage = '') or PrepareToInstallNeedsRestart;
     else
     else
       NextButton.Enabled := True;
       NextButton.Enabled := True;
     end;
     end;
@@ -2085,6 +2116,7 @@ var
   PageIndex: Integer;
   PageIndex: Integer;
   Continue: Boolean;
   Continue: Boolean;
   NewPageID: Integer;
   NewPageID: Integer;
+  RestartManagerResult: String;
 label Again;
 label Again;
 begin
 begin
   if CurPageID = wpInstalling then
   if CurPageID = wpInstalling then
@@ -2146,6 +2178,12 @@ begin
             LogFmt('PrepareToInstall failed: %s', [PrepareToInstallFailureMessage]);
             LogFmt('PrepareToInstall failed: %s', [PrepareToInstallFailureMessage]);
             LogFmt('Need to restart Windows? %s', [SYesNo[PrepareToInstallNeedsRestart]]);
             LogFmt('Need to restart Windows? %s', [SYesNo[PrepareToInstallNeedsRestart]]);
             Break;  { stop on the page }
             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;
         end;
         end;
       wpInstalling: begin
       wpInstalling: begin
@@ -2565,7 +2603,7 @@ var
   BeforeID: Integer;
   BeforeID: Integer;
 begin
 begin
   while True do 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
       { Special handling needed for wpPreparing since it displays its error
         message inline on the wizard. Since the wizard isn't currently visible,
         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
         we have to display the messsage in a message box if it won't be displayed