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

Inno Setup Disable Next button when input is not valid

当输入不是 "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; 

实现输入框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;

要合并多个验证,请参阅

有关其他方法,请参阅:

  • ;
  • .