首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

delphi中下面的seltext以及Text获取的是什么值 多谢啊

2012-02-12 
delphi中下面的seltext以及Text获取的是什么值 谢谢啊 求助procedure TEditNum.keypress(var key:char)va

delphi中下面的seltext以及Text获取的是什么值 谢谢啊 求助
procedure TEditNum.keypress(var key:char);
var
x,p1,p2,pp1,pp2,p:integer;
tp:Tpoint;
s:string;
begin
  if key in ['0'..'9','+','-','.'] then
  begin
  s:=trim(seltext);
  p1:=pos('+',Text)+pos('-',Text);
  p2:=pos('.',Text);
  pp1:=pos('+',s)+pos('-',s);
  pp2:=pos('.',s);
  if self.Ctl3D then p:=1 else p:=2;
  if (trim(text)=trim(seltext)) then x:=1
  else x:=0;
  GetCaretPos(tp);
  if (isfull)and(s='') then key:=#0;
  if (tp.x=p)and(p1>0)and(pp1=0)and(x=0) then key:=#0;
  if (key='+')or(key='-') then
  if ((p1>0)or(tp.x>p))and(pp1=0)and(x=0) then key:=#0;
  if (key='.') then
  if ((p2>0)and(pp2=0)and(x=0))or(flength2<=0) then key:=#0;
  end
  else if key>#31 then key:=#0;
  if key<>#0 then fkeysgn:=1;
  inherited keypress(key);
end;

[解决办法]
SelText是一個編輯框選擇的文字(字符),Text是一個編輯框全部的文字(字符)。你上面的程式是用來輸入數字的。

热点排行