Inno Setup Disable Next button when input is not valid

前端 未结 1 471
暗喜
暗喜 2020-12-10 00:14

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

Something like:

procedure EditKeyPres         


        
相关标签:
1条回答
  • 2020-12-10 00:32

    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:

    • Inno Setup - Create User Input Query Page with input length and format limit and use the input;
    • Validate data on custom page when Next button is clicked in Inno Setup.
    0 讨论(0)
提交回复
热议问题