加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

inno-setup – 如何限制用户输入目录编辑框?

发布时间:2020-12-15 09:12:16 所属栏目:大数据 来源:网络整理
导读:我需要阻止用户进入.在目录编辑框中输入的路径的末尾. 例如,路径不能是: C:Program FilesInnoSetup. 如何验证目录编辑框输入,或者如何阻止用户输入.到路的尽头? 解决方法 要自动删除目标目录末尾的所有点,可以使用此脚本.你没有回答我的问题,在路径末端
我需要阻止用户进入.在目录编辑框中输入的路径的末尾.

例如,路径不能是:

C:Program FilesInnoSetup.

如何验证目录编辑框输入,或者如何阻止用户输入.到路的尽头?

解决方法

要自动删除目标目录末尾的所有点,可以使用此脚本.你没有回答我的问题,在路径末端找到一个点时你想做什么,所以我选择这种方式来显示.请注意,这将删除文件夹字符串末尾的所有点,因此从以下路径中删除:

C:Program Files (x86)My Program.....

这个脚本使:

C:Program Files (x86)My Program

这是脚本:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}My Program

[code]
procedure OnDirEditChange(Sender: TObject);
var
  S: string;
begin
  S := WizardDirValue;
  if (Length(S) > 0) and (S[Length(S)] = '.') then
  begin
    MsgBox('Last char(s) of the entered target folder is "."' + #13#10 +
      'All "." chars from the end will be deleted!',mbInformation,MB_OK);
    while (Length(S) > 0) and (S[Length(S)] = '.') do
      Delete(S,Length(S),1);
    WizardForm.DirEdit.Text := S;
  end;
end;

procedure InitializeWizard;
begin  
  WizardForm.DirEdit.OnChange := @OnDirEditChange;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  // this is just a paranoid event trigger,in case the DefaultDirName
  // would be able to contain dots at the end,what can't at this time
  if CurPageID = wpSelectDir then
    OnDirEditChange(nil);
end;

当然还有另一种验证路径的方法,例如,让用户在结尾处输入带点的路径,并在移动到向导中的下一步时对其进行验证等.但是您没有指定您对如何编写验证问题的意思.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读