【问题标题】:How to jump to page on on button click?如何在按钮单击时跳转到页面?
【发布时间】:2014-03-04 02:15:24
【问题描述】:

我需要一个简单的东西:有提前和正常安装按钮。对于正常情况,这很简单——我使用默认的下一步按钮和 NextButtonClick 上的一些逻辑来设置条件变量并使用 ShouldSkipPage 跳过一些页面。然而,对于高级设置,我创建了一个新按钮,点击后我需要做的就是打开下一个安装程序页面:

procedure CurPageChanged(CurPageID : Integer);
begin
if CurPageID = wpWelcome then begin
    AdvancedButton := TButton.Create(WizardForm);
    AdvancedButton.Caption := 'Advanced Install';
    AdvancedButton.Left := WizardForm.InfoAfterPage.Left + 10;
    AdvancedButton.Top := WizardForm.InfoAfterPage.Height + 88;
    AdvancedButton.Parent := WizardForm.NextButton.Parent;
    # AdvancedButton.OnClick :=  What shall I call to open say next page (or some page by given PageID value)
    end
    else begin
    AdvancedButton.Visible := False;
    end;

end;

那么我应该调用什么来打开按钮单击时的下一页(或给定 PageID 值的某些页面)(在 Inno API 中找不到任何 NextPage 或某些 SetPage 函数)?

【问题讨论】:

  • OT:首先在控件创建后将Parent 属性设置为控件。最好这样做,因为您可能希望通过其父级应用控件对齐,并且您可能会在分配父级之前错误地添加此类行。

标签: windows installation inno-setup pascal


【解决方案1】:

在 Inno Setup 中没有“直接跳转到页面”之类的东西。 您只需在“高级模式”中安静地跳过某些页面即可。

只需执行与常规安装程序相同的操作即可。设置一个变量来保持“高级模式”。点击前进按钮后:

[Code]
var
  IsAdvanced: Boolean;

procedure AdvancedButtonClick(Sender: TObject);
begin
  IsAdvanced := True;
  WizardForm.NextButton.OnClick(nil);
end;

procedure InitializeWizard;
var
  AdvancedButton: TNewButton;
begin
  // not necessary; just for sure
  IsAdvanced := False;
  // create the button
  AdvancedButton := TNewButton.Create(WizardForm);
  AdvancedButton.Caption := 'Advanced Install';
  AdvancedButton.Left := WizardForm.InfoAfterPage.Left + 10;
  AdvancedButton.Top := WizardForm.InfoAfterPage.Height + 88;
  AdvancedButton.Parent := WizardForm.NextButton.Parent;
  AdvancedButton.OnClick := @AdvancedButtonClick;
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  // the <page where you want to end up> fill with the wizard page constant
  // of the page where you want to end up, e.g. wpReady
  Result := IsAdvanced and (PageID <> <page where you want to end up>);
end;

使用此逻辑,您可以模拟安静地“跳转”到某个页面。

【讨论】:

  • 请注意,页面不一定按数字 ID 顺序显示,因此这可能会导致跳过非预期页面。此外,它需要跳过 IsAdvanced 选项本身所在的页面,否则用户可能会在单击“返回”改变主意时感到惊讶。
  • 不需要用户点击高级和下一步吗?我想让他只点击一个按钮 - 这是我的主要观点。
  • 是的,会的。但是,您可以模拟我在编辑中显示的下一个按钮单击(Slappy,我希望您不介意我的拦截:-)
猜你喜欢
  • 1970-01-01
  • 2016-04-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多