zoukankan      html  css  js  c++  java
  • [Inno Setup] How to create a OuterNotebook/welcome page in the uninstaller

    By Martin Prikryl

    https://stackoverflow.com/questions/42625626/inno-setup-how-to-create-a-outernotebook-welcome-page-in-the-uninstaller

    You create the page as any other, except that its parent will be the UninstallProgressForm.OuterNotebook, not the .InnerNotebook.

    Tricky part is not how to create the page, but how to implement the Next/Back buttons.

    The Next button on the "welcome" page must change the page of the OuterNotebook from the "welcome" page to the UninstallProgressForm.InnerPage. And of course make sure the active page on the .InnerNotebook is the first normal/inner page.

    Conversely, the Back button on the first normal/inner page must change the page of the OuterNotebook from the UninstallProgressForm.InnerPage to the "welcome" page.

    So modifying my answer to the Custom Uninstall page (not MsgBox) to cater for the above, you will get:

    [Files]
    Source: "compiler:WizModernImage-IS.bmp"; DestDir: {app}
    
    [Code]
    
    var
      UninstallWelcomePage: TNewNotebookPage;
      UninstallFirstPage: TNewNotebookPage;
      UninstallSecondPage: TNewNotebookPage;
      UninstallBackButton: TNewButton;
      UninstallNextButton: TNewButton;
    
    procedure UpdateUninstallWizard;
    begin
      if UninstallProgressForm.InnerNotebook.ActivePage = UninstallFirstPage then
      begin
        UninstallProgressForm.PageNameLabel.Caption := 'First uninstall wizard page';
        UninstallProgressForm.PageDescriptionLabel.Caption :=
          'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
      end
        else
      if UninstallProgressForm.InnerNotebook.ActivePage = UninstallSecondPage then
      begin
        UninstallProgressForm.PageNameLabel.Caption := 'Second uninstall wizard page';
        UninstallProgressForm.PageDescriptionLabel.Caption :=
          'Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';
      end;
    
      UninstallBackButton.Visible :=
        (UninstallProgressForm.OuterNotebook.ActivePage <> UninstallWelcomePage);
    
      if UninstallProgressForm.InnerNotebook.ActivePage <> UninstallSecondPage then
      begin
        UninstallNextButton.Caption := SetupMessage(msgButtonNext);
        UninstallNextButton.ModalResult := mrNone;
      end
        else
      begin
        UninstallNextButton.Caption := 'Uninstall';
        { Make the "Uninstall" button break the ShowModal loop }
        UninstallNextButton.ModalResult := mrOK;
      end;
    end;  
    
    procedure UninstallNextButtonClick(Sender: TObject);
    begin
      if UninstallProgressForm.OuterNotebook.ActivePage = UninstallWelcomePage then
      begin
        UninstallProgressForm.OuterNotebook.ActivePage := UninstallProgressForm.InnerPage;
        UninstallProgressForm.InnerNotebook.ActivePage := UninstallFirstPage;
        UpdateUninstallWizard;
      end
        else
      begin
        if UninstallProgressForm.InnerNotebook.ActivePage <> UninstallSecondPage then
        begin
          if UninstallProgressForm.InnerNotebook.ActivePage = UninstallFirstPage then
          begin
            UninstallProgressForm.InnerNotebook.ActivePage := UninstallSecondPage;
          end;
          UpdateUninstallWizard;
        end
          else
        begin
          UninstallNextButton.Visible := False;
          UninstallBackButton.Visible := False;
        end;
      end;
    end;
    
    procedure UninstallBackButtonClick(Sender: TObject);
    begin
      if UninstallProgressForm.InnerNotebook.ActivePage = UninstallFirstPage then
      begin
        UninstallProgressForm.OuterNotebook.ActivePage := UninstallWelcomePage;
      end
        else
      if UninstallProgressForm.InnerNotebook.ActivePage = UninstallSecondPage then
      begin
        UninstallProgressForm.InnerNotebook.ActivePage := UninstallFirstPage;
      end;
    
      UpdateUninstallWizard;
    end;
    
    procedure InitializeUninstallProgressForm();
    var
      PageText: TNewStaticText;
      UninstallWizardBitmapImage: TBitmapImage;
      PageNameLabel: string;
      PageDescriptionLabel: string;
      CancelButtonEnabled: Boolean;
      CancelButtonModalResult: Integer;
    begin
      if not UninstallSilent then
      begin
        PageNameLabel := UninstallProgressForm.PageNameLabel.Caption;
        PageDescriptionLabel := UninstallProgressForm.PageDescriptionLabel.Caption;
    
        { Create the Welcome page and make it active }
        UninstallWelcomePage := TNewNotebookPage.Create(UninstallProgressForm);
        UninstallWelcomePage.Notebook := UninstallProgressForm.OuterNotebook;
        UninstallWelcomePage.Parent := UninstallProgressForm.OuterNotebook;
        UninstallWelcomePage.Align := alClient;
        UninstallWelcomePage.Color := clWindow;
    
        UninstallWizardBitmapImage := TBitmapImage.Create(UninstallProgressForm);
        UninstallWizardBitmapImage.Parent := UninstallWelcomePage;
        UninstallWizardBitmapImage.Width := ScaleX(164);
        UninstallWizardBitmapImage.Height := ScaleX(314);
        UninstallWizardBitmapImage.Bitmap.LoadFromFile(
          ExpandConstant('{app}WizModernImage-IS.bmp'));
        UninstallWizardBitmapImage.Center := True;
        UninstallWizardBitmapImage.Stretch := True;
    
        PageText := TNewStaticText.Create(UninstallProgressForm);
        PageText.Parent := UninstallWelcomePage;
        PageText.Left := ScaleX(176);
        PageText.Top := ScaleX(16);
        PageText.Width := ScaleX(301);
        PageText.Height := ScaleX(54);
        PageText.AutoSize := False;
        PageText.Caption := 'Welcome to the My Program uninstall wizard';
        PageText.ShowAccelChar := False;
        PageText.WordWrap := True;
        PageText.Font.Name := 'Verdana';
        PageText.Font.Size := 12;
        PageText.Font.Style := [fsBold];
    
        PageText := TNewStaticText.Create(UninstallProgressForm);
        PageText.Parent := UninstallWelcomePage;
        PageText.Left := ScaleX(176);
        PageText.Top := ScaleX(76);
        PageText.Width := ScaleX(301);
        PageText.Height := ScaleX(234);
        PageText.AutoSize := False;
        PageText.Caption :=
          'This will uninstall My Program 1.5 from your computer.'#13#10#13#10 +
          'It is recommended that your close all other applications before continuing.' +
            #13#10#13#10 +
          'Click Next to continue, or Cancel to exit Uninstall.';
        PageText.ShowAccelChar := False;
        PageText.WordWrap := True;
    
        UninstallProgressForm.OuterNotebook.ActivePage := UninstallWelcomePage;
    
        { Create the first page }
        UninstallFirstPage := TNewNotebookPage.Create(UninstallProgressForm);
        UninstallFirstPage.Notebook := UninstallProgressForm.InnerNotebook;
        UninstallFirstPage.Parent := UninstallProgressForm.InnerNotebook;
        UninstallFirstPage.Align := alClient;
    
        PageText := TNewStaticText.Create(UninstallProgressForm);
        PageText.Parent := UninstallFirstPage;
        PageText.Top := UninstallProgressForm.StatusLabel.Top;
        PageText.Left := UninstallProgressForm.StatusLabel.Left;
        PageText.Width := UninstallProgressForm.StatusLabel.Width;
        PageText.Height := UninstallProgressForm.StatusLabel.Height;
        PageText.AutoSize := False;
        PageText.ShowAccelChar := False;
        PageText.Caption := 'Press Next to proceeed with uninstallation.';
    
        { Create the second page }
        UninstallSecondPage := TNewNotebookPage.Create(UninstallProgressForm);
        UninstallSecondPage.Notebook := UninstallProgressForm.InnerNotebook;
        UninstallSecondPage.Parent := UninstallProgressForm.InnerNotebook;
        UninstallSecondPage.Align := alClient;
    
        PageText := TNewStaticText.Create(UninstallProgressForm);
        PageText.Parent := UninstallSecondPage;
        PageText.Top := UninstallProgressForm.StatusLabel.Top;
        PageText.Left := UninstallProgressForm.StatusLabel.Left;
        PageText.Width := UninstallProgressForm.StatusLabel.Width;
        PageText.Height := UninstallProgressForm.StatusLabel.Height;
        PageText.AutoSize := False;
        PageText.ShowAccelChar := False;
        PageText.Caption := 'Press Uninstall to proceeed with uninstallation.';
    
        UninstallNextButton := TNewButton.Create(UninstallProgressForm);
        UninstallNextButton.Parent := UninstallProgressForm;
        UninstallNextButton.Left :=
          UninstallProgressForm.CancelButton.Left -
          UninstallProgressForm.CancelButton.Width -
          ScaleX(10);
        UninstallNextButton.Top := UninstallProgressForm.CancelButton.Top;
        UninstallNextButton.Width := UninstallProgressForm.CancelButton.Width;
        UninstallNextButton.Height := UninstallProgressForm.CancelButton.Height;
        UninstallNextButton.OnClick := @UninstallNextButtonClick;
    
        UninstallBackButton := TNewButton.Create(UninstallProgressForm);
        UninstallBackButton.Parent := UninstallProgressForm;
        UninstallBackButton.Left :=
          UninstallNextButton.Left - UninstallNextButton.Width - ScaleX(10);
        UninstallBackButton.Top := UninstallProgressForm.CancelButton.Top;
        UninstallBackButton.Width := UninstallProgressForm.CancelButton.Width;
        UninstallBackButton.Height := UninstallProgressForm.CancelButton.Height;
        UninstallBackButton.Caption := SetupMessage(msgButtonBack);
        UninstallBackButton.OnClick := @UninstallBackButtonClick;
        UninstallBackButton.TabOrder := UninstallProgressForm.CancelButton.TabOrder;
    
        UninstallNextButton.TabOrder := UninstallBackButton.TabOrder + 1;
    
        UninstallProgressForm.CancelButton.TabOrder := UninstallNextButton.TabOrder + 1;
    
        { Run our wizard pages } 
        UpdateUninstallWizard;
        CancelButtonEnabled := UninstallProgressForm.CancelButton.Enabled
        UninstallProgressForm.CancelButton.Enabled := True;
        CancelButtonModalResult := UninstallProgressForm.CancelButton.ModalResult;
        UninstallProgressForm.CancelButton.ModalResult := mrCancel;
    
        if UninstallProgressForm.ShowModal = mrCancel then Abort;
    
        { Restore the standard page payout }
        UninstallProgressForm.CancelButton.Enabled := CancelButtonEnabled;
        UninstallProgressForm.CancelButton.ModalResult := CancelButtonModalResult;
    
        UninstallProgressForm.PageNameLabel.Caption := PageNameLabel;
        UninstallProgressForm.PageDescriptionLabel.Caption := PageDescriptionLabel;
    
        UninstallProgressForm.InnerNotebook.ActivePage :=
          UninstallProgressForm.InstallingPage;
      end;
    end;

    Note that there's no way to use the built-in images from the installer in the uninstaller. In my simple code above, I install the "welcome" page image to the {app} and load it from there.

    If you want to avoid this, see my answer to the How keep uninstall files inside uninstaller?

  • 相关阅读:
    web工作流管理系统开发之三 可视化流程设计器
    做统计报表常用的设计思路
    一个请求从 URL 字符串到 HTML 代码的“漫长曲折”之路
    webparts中,此页当前禁用指定的显示模式。请确保为当前用户启用了个性化设置。
    一个多线程应用的最佳示例
    web工作流管理系统开发之一 工作流概念
    在线报表采集汇总系统的需求
    几种web报表打印方案的比较
    web报表开发技术专题五:Excel的阴影
    中国报表漫谈
  • 原文地址:https://www.cnblogs.com/liujx2019/p/10904782.html
Copyright © 2011-2022 走看看