当输入无效时,Inno Setup禁用下一步按钮

时间:2017-05-02 12:53:38

标签: inno-setup

当输入不是“Admin”时,我需要禁用 Next 按钮。

类似的东西:

procedure EditKeyPress(Sender: TObject; var Key: Char);
begin
  { enable the next button if the value in the box is admin; disable otherwise }
  WizardForm.NextButton.Enabled:=InputPage6.values[EditIndex2]‌​.Text = 'Admin'
end; 

1 个答案:

答案 0 :(得分:3)

实施输入框OnChange事件。您还需要确保在激活自定义页面时更新按钮状态。您可以使用OnActivate事件(或CurPageChanged事件函数)。

var
  Page: TInputQueryWizardPage;

procedure ValidatePage;
begin
  WizardForm.NextButton.Enabled := (CompareText(Page.Values[0], 'Admin') = 0);
end;  

procedure EditChange(Sender: TObject);
begin
  ValidatePage;
end;

procedure PageActivate(Sender: TWizardPage);
begin
  ValidatePage;
end;

procedure InitializeWizard();
begin
  Page := CreateInputQueryPage(...);
  { To disable the Next button initially [when box is empty] }
  Page.OnActivate := @PageActivate;
  Page.Add(..., False);
  { Update Next button state on any input change (typing, copy&paste, whatever) }
  Page.Edits[0].OnChange := @EditChange;
end;

要结合多个验证,请参阅Inno Setup Disable Next button using multiple validation expressions (when input value matches one of multiple values)

有关其他方法,请参阅: