Delphi   发布时间:2022-04-11  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了inno-setup – 在Inno Setup的文本框中需要一个数字大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在这里找到了一个我需要的代码.仅允许在文本框中写入数字.但我仍然想要更多,没有提供“下一步”按钮而没有在此文本框中写入数字.

可以帮我?

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;

大佬总结

以上是大佬教程为你收集整理的inno-setup – 在Inno Setup的文本框中需要一个数字全部内容,希望文章能够帮你解决inno-setup – 在Inno Setup的文本框中需要一个数字所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。