在Inno Setup中进行数据输入的端口范围验证 [英] Port range validation for data input in Inno Setup
本文介绍了在Inno Setup中进行数据输入的端口范围验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试设置安装期间用户输入接受的特定值范围.例如,端口字段只接受10000-20000的范围.
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.
我尝试在NextButtonClick
甚至其他条件下使用此条件.我在Pascal文档中进行了搜索,但是我没有找到该怎么做的方法,否则在此之前没有任何问题可以针对特定范围设置数据验证.
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.
我的代码如下:
[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;
推荐答案
只需验证输入,显示错误消息并确保NextButtonClick
事件函数返回False
:
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;
这篇关于在Inno Setup中进行数据输入的端口范围验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文