我在inno中创建了一个自定义向导页面,需要在将文件安装到{app}文件夹后显示.这是通过给出wpInfoAfter来实现的.问题是,它只显示"下一步"按钮,没有取消/返回按钮,右上角的对话框关闭按钮也被禁用.我知道不需要后退按钮,因为它需要删除已安装的文件.无论如何可以显示"取消"按钮吗?
该Cancel按钮在安装后阶段没有任何功能,因为InnoSetup不希望在安装过程完成后执行需要取消的进一步操作.因此,即使您针对该事实显示按钮,您也会得到一个没有任何操作的按钮.
我个人更愿意在安装开始之前收集设置数据库所需的信息,因为考虑用户安装应用程序时的情况,只需取消安装后向导(很容易发生).之前,您可以强制用户在实际访问应用程序之前填写所需内容.但是如果您仍然希望在安装后执行此操作,则可以找到缺少取消按钮的解决方法.
作为一种变通方法,您可以创建自己的自定义按钮,它将位于具有相同功能的相同位置.这是一个示例脚本,模拟取消按钮并仅在安装过程后放置的自定义页面上显示它.这只是一种解决方法,因为您至少需要解决此问题:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Code]
procedure ExitProcess(uExitCode: UINT);
external 'ExitProcess@kernel32.dll stdcall';
var
CustomPage: TWizardPage;
CancelButton: TNewButton;
procedure OnCancelButtonClick(Sender: TObject);
begin
// confirmation "Exit setup ?" message, if user accept, then...
if ExitSetupMsgBox then
begin
// stop and rollback actions you did from your after install
// process and kill the setup process itself
ExitProcess(0);
end;
end;
procedure InitializeWizard;
begin
// create a custom page
CustomPage := CreateCustomPage(wpInfoAfter, 'Caption', 'Description');
// create a cancel button, set its parent, hide it, setup the bounds
// and caption by the original and assign the click event
CancelButton := TNewButton.Create(WizardForm);
CancelButton.Parent := WizardForm;
CancelButton.Visible := False;
CancelButton.SetBounds(
WizardForm.CancelButton.Left,
WizardForm.CancelButton.Top,
WizardForm.CancelButton.Width,
WizardForm.CancelButton.Height
);
CancelButton.Caption := SetupMessage(msgButtonCancel);
CancelButton.OnClick := @OnCancelButtonClick;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
// show your fake Cancel button only when you're on some of your after
// install pages; if you have more pages use something like this
// CancelButton.Visible := (CurPageID >= FirstPage.ID) and
// (CurPageID <= LastPage.ID);
// if you have just one page, use the following instead
CancelButton.Visible := CurPageID = CustomPage.ID;
end;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2044 次 |
| 最近记录: |