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

inno-setup – 在Inno Setup的文本框中需要一个数字

发布时间:2020-12-15 04:30:11 所属栏目:大数据 来源:网络整理
导读:我在这里找到了一个我需要的代码.仅允许在文本框中写入数字.但我仍然想要更多,没有提供“下一步”按钮而没有在此文本框中写入数字. 可以帮我? procedure NumbersOnly(Sender: TObject; var Key: Char);var S: string;begin S := ('1234567890'#8); if Pos(K
我在这里找到了一个我需要的代码.仅允许在文本框中写入数字.但我仍然想要更多,没有提供“下一步”按钮而没有在此文本框中写入数字.

可以帮我?

procedure NumbersOnly(Sender: TObject; var Key: Char);
var
  S: string;
begin
  S := ('1234567890'#8);
  if Pos(Key,S) = 0 then 
    Key := #0;
end;

解决方法

当用户到达编辑框所在的页面时,您可以在 CurPageChanged事件中设置要启用或禁用的下一个按钮.除非您需要监视该编辑框的更改,以根据是否在该编辑框中输入了某些内容来启用或禁用下一个按钮.为此,您需要为OnChange事件编写处理程序.这是一个例子:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}My Program

[Code]
var
  MyEdit: TNewEdit;
  MyPage: TWizardPage;

procedure MyEditChange(Sender: TObject);
begin
  { enable the next button if the edit box is not empty; disable otherwise }
  WizardForm.NextButton.Enabled := MyEdit.Text <> '';
end;

procedure MyEditKeyPress(Sender: TObject; var Key: Char);
var
  KeyCode: Integer;
begin
  { allow only numbers }
  KeyCode := Ord(Key);
  if not ((KeyCode = 8) or ((KeyCode >= 48) and (KeyCode <= 57))) then
    Key := #0;
end;

procedure InitializeWizard;
begin
  MyPage := CreateCustomPage(wpWelcome,'Caption','Description');

  MyEdit := TNewEdit.Create(WizardForm);
  MyEdit.Parent := MyPage.Surface;
  MyEdit.Left := 0;
  MyEdit.Top := 0;
  MyEdit.Width := 150;
  MyEdit.OnChange := @MyEditChange;
  MyEdit.OnKeyPress := @MyEditKeyPress;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  { if the currently turned wizard page is the one with the edit box,enable }
  { the next button if the edit box is not empty; disable otherwise }
  if CurPageID = MyPage.ID then
    WizardForm.NextButton.Enabled := MyEdit.Text <> '';
end;

(编辑:李大同)

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

    推荐文章
      热点阅读