问题
I try to set specific range of values that accepted from user inputs within installation. For example, port field just accept range from 10000-20000.
I try to use this condition in NextButtonClick
or even other. I searched in Pascal documentation, but I didn't find how to do that, else there is no question asked before here to set data validation for specific range.
My code as below:
[Code]
var
AdminDataPage: TInputQueryWizardPage;
Name, SuperPassword, ServerName, ServerPort : String;
function CreateAdminDataPage(): Integer;
begin
AdminDataPage := CreateInputQueryPage(wpSelectDir, 'Required Information', '', '');
AdminDataPage.Add('Name', False);
AdminDataPage.Add('SuperPassword', True);
AdminDataPage.Add('ServerName', False);
AdminDataPage.Add('ServerPort', False);
end;
procedure CreateAdminDataPage();
begin
CreateDataInputPage();
end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
if CurPageID = AdminDataPage.ID then
begin
Name := AdminDataPage.values[0];
SuperPassword := AdminDataPage.values[1];
ServerName := AdminDataPage.values[2];
ServerPort := AdminDataPage.values[3];
end;
end;
回答1:
Just validate the input, display error message and make sure the NextButtonClick
event function returns False
:
function NextButtonClick(CurPageID: Integer): Boolean;
var
ServerPortInt: Integer;
begin
Result := True;
if CurPageID = AdminDataPage.ID then
begin
ServerPort := AdminDataPage.Values[3];
ServerPortInt := StrToIntDef(ServerPort, -1);
if (ServerPortInt < 10000) or (ServerPortInt > 20000) then
begin
MsgBox('Please enter port in range 10000-20000.', mbError, MB_OK);
WizardForm.ActiveControl := AdminDataPage.Edits[3];
Result := False;
end;
end;
end;
来源:https://stackoverflow.com/questions/53917243/port-range-validation-for-data-input-in-inno-setup