Inno Setup - 如何在卸载程序中创建 OuterNotebook/welcome 页面?
Inno Setup - How to create a OuterNotebook/welcome page in the uninstaller?
我正在使用 Martin Prikryl 对 Custom Uninstall page (not MsgBox) 的回答中的这段代码。
如何修改此代码的第一页以在 OuterNotebook
页面上显示类似 "Welcome" 的页面(即没有 MainPanel
header)?
您可以像创建其他页面一样创建页面,只是其父级将是 UninstallProgressForm.OuterNotebook
,而不是 .InnerNotebook
。
棘手的部分不是如何创建页面,而是如何实现 Next/Back 按钮。
下一页按钮必须将"welcome"页面从"welcome"页面更改为[=14]页面OuterNotebook
=].当然,还要确保 .InnerNotebook
上的活动页面是第一个 normal/inner 页面。
相反,第一个 normal/inner 页面上的 后退 按钮必须将 OuterNotebook
的页面从 UninstallProgressForm.InnerPage
更改为 "welcome"页。
因此修改我对 Custom Uninstall page (not MsgBox) 的回答以迎合上述内容,您将得到:
[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;
请注意,无法在卸载程序中使用安装程序的内置图像。在我上面的简单代码中,我将 "welcome" 页面图像安装到 {app}
并从那里加载它。
如果您想避免这种情况,请参阅我对 How keep uninstall files inside uninstaller?
的回答
我正在使用 Martin Prikryl 对 Custom Uninstall page (not MsgBox) 的回答中的这段代码。
如何修改此代码的第一页以在 OuterNotebook
页面上显示类似 "Welcome" 的页面(即没有 MainPanel
header)?
您可以像创建其他页面一样创建页面,只是其父级将是 UninstallProgressForm.OuterNotebook
,而不是 .InnerNotebook
。
棘手的部分不是如何创建页面,而是如何实现 Next/Back 按钮。
下一页按钮必须将"welcome"页面从"welcome"页面更改为[=14]页面OuterNotebook
=].当然,还要确保 .InnerNotebook
上的活动页面是第一个 normal/inner 页面。
相反,第一个 normal/inner 页面上的 后退 按钮必须将 OuterNotebook
的页面从 UninstallProgressForm.InnerPage
更改为 "welcome"页。
因此修改我对 Custom Uninstall page (not MsgBox) 的回答以迎合上述内容,您将得到:
[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;
请注意,无法在卸载程序中使用安装程序的内置图像。在我上面的简单代码中,我将 "welcome" 页面图像安装到 {app}
并从那里加载它。
如果您想避免这种情况,请参阅我对 How keep uninstall files inside uninstaller?
的回答