zoukankan      html  css  js  c++  java
  • SetEditOnePoint() 使Edit控件中只能输入数字和1个小数点


    {使Edit控件中只能输入数字和1个小数点 }
    // 调用 放在Edit的KeyPress事件下 setOnePoint(Key,Edit1);
    procedure SetEditOnePoint(var Key: Char;CTRL:Tedit);
    var p:integer; tp:TPoint;
    begin
       if key in['0'..'9','+','-','.'] then
          begin
             if key in['+','-'] then
                 begin
                   p:=pos('+',CTRL.Text)+pos('-',CTRL.Text);
                   if p>0 then
                      key:=#0
                   else
                      begin
                         GetCaretPos(tp);
                         if tp.x>1 then key:=#0;
                      end;
                 end
             else  if key='.' Then
                 begin
                    p:=pos('.',CTRL.Text);
                    if p>0 then key:=#0;
                 end;
          end
       else if key>#31 then key:=#0;
    end;




  • 相关阅读:
    模拟
    广搜——最优方案
    动态规划——背包
    动态规划——树规
    动态规划——区间
    fill 的用法
    状态压缩dp
    超大背包问题
    lower_bound
    弹性碰撞 poj 3684
  • 原文地址:https://www.cnblogs.com/xe2011/p/2609330.html
Copyright © 2011-2022 走看看