zoukankan      html  css  js  c++  java
  • numEdit

    说明:  利用tedit扩展的数字编辑框,允许设置正负、小数点等
    (The digital edit box using tedit extended, allowing the set of positive and negative, the decimal point)

    unit numEdit;
    
    interface
    
    uses
      SysUtils, Classes, Controls, StdCtrls;
    
    type
      TnumEdit = class(TEdit)
      private
        { Private declarations }
    
        fallowe:boolean;
        fallownegative:boolean;//允许负数
        fallowpoint:boolean;
        fallowAll:boolean;
      protected
        { Protected declarations }
        procedure KeyPress(var Key: Char);override;
      public
        { Public declarations }
        function asint:integer;
        function asfloat:double;
      published
        { Published declarations }
        property allowe:boolean read fallowe write fallowe default false;
        property allownegative:boolean read fallownegative write fallownegative default false;
        property allowpoint:boolean read fallowpoint write fallowpoint default false;
        
        property allowAll:boolean read fallowall write fallowall default false;
      end;
    
    procedure Register;
    
    implementation
    
    procedure Register;
    begin
      RegisterComponents('System', [TnumEdit]);
    end;
    
    
    { TnumEdit }
    
    function TnumEdit.asfloat: double;
    var
    tmpf:double;
    begin
      try
        tmpf:=strtofloat(text);
      except
        tmpf:=-1;
      end;
      result:=tmpf;
    
    end;
    
    function TnumEdit.asint: integer;
    var
    tmpn:integer;
    begin
      try
        tmpn:=strtoint(text);
      except
        tmpn:=-1;
      end;
      result:=tmpn;
    end;
    
    procedure TnumEdit.KeyPress(var Key: Char);
    begin
      inherited;
      if fallowall then exit;
      if not (((ord(key)>=48) and  //数字
              (ord(key)<=57)) or  //
              (ord(key)=8) or   //删除
              ((ord(key)=46) and fallowpoint) or  //.
              ((ord(key)=45) and fallownegative) or  //-
              (((ord(key)=101) or (ord(key)=69)) and fallowe))//e
              then
        key:=#0;
    end;
    
    end.
  • 相关阅读:
    js 数据图表
    yii query builder
    mysql if
    这又是起点
    [cookie篇]从cookie-parser中间件说起
    How to find and fix Bash Shell-shock vulnerability CVE-2014-6271 in unix like system
    AngularJS打印问题
    笔记本上班时间自动静音下班自动打开
    SCP命令
    Installing Ruby 1.9.3 on Ubuntu 12.04 Precise Pengolin (without RVM)
  • 原文地址:https://www.cnblogs.com/jijm123/p/10013772.html
Copyright © 2011-2022 走看看