Страница 1 из 1

Свойства edit ?

Добавлено: 10 авг 2004, 21:32
Hellspawn
Вот столкнулся с проблемой, нужно чтобы в edit можно было вводить цифры 0-9, буквы a-f и все как это реализовать ?

Добавлено: 11 авг 2004, 00:28
Naeel Maqsudov
Я так понимаю речь о 16-ричных числах? :)

Надо обратотать событие OnKeyPressed у этого поля:

Код: Выделить всё

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
  if Key in [#8,'0'..'9','a'..'f'] then Key:=System.UpCase(Key) else Key:=#0;
end;

Добавлено: 13 авг 2004, 01:19
Hellspawn
Вот разобрался !! работающий пример:

Код: Выделить всё

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
label m1;
var col:dword;
begin
 col:=ord(key);
 If col < $30 then begin
  If (col=$8) or (col=$20) or (col=$3) then goto m1 else
  Key := #0;
  end else;
 If col > $66 then  Key := #0 else
 If col > $46 then begin
    If col <$61 then  Key := #0 else
    end else;
 If col > $39 then begin
    If col < $41 then Key := #0 else
    end else;
m1:
end;
end.
или так

Код: Выделить всё

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); 
begin 
  if Key in [#8,#20,#3,'0'..'9','a'..'f'] then Key:=System.UpCase(Key) else Key:=#0; 
end;
end.