Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
969 views
in Technique[技术] by (71.8m points)

installation - Inno Setup Disable Next button when input is not valid

I need to disable Next button, when input is not "Admin".

Something like:

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; 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Implement the input box OnChange event. You will also need to make sure the button state is updated, when the custom page is activated. You can use OnActivate event for that (or CurPageChanged event function).

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;

To combine multiple validations, see Inno Setup Disable Next button using multiple validation expressions (when input value matches one of multiple values).

For other approaches, see:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...