Inno Setup 在输入无效时禁用 Next 按钮

Swe*_*per 2 installation inno-setup pascalscript

当输入不是“管理员”时,我需要禁用下一步按钮。

就像是:

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; 
Run Code Online (Sandbox Code Playgroud)

Mar*_*ryl 6

实现输入框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;
Run Code Online (Sandbox Code Playgroud)

要组合多个验证,请参阅Inno Setup Disable Next 按钮使用多个验证表达式(当输入值匹配多个值之一时)

对于其他方法,请参阅: