type
TNumEdit = class(TEdit)
procedure CreateParams(var Params: TCreateParams); override;
procedure KeyPress(var Key: Char); override;
end;
procedure register;
implementation
procedure register;
begin
RegisterComponents('Standard', [TNumEdit]);
end;
procedure TNumEdit.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.Style := Params.Style or ES_MULTILINE or ES_RIGHT;
end;
procedure TNumEdit.KeyPress(var Key: Char);
begin
case key of
'0'..'9': ; // цифры
#8: ; // забой
'.', ',':
if Pos(DecimalSeparator, Text) = 0 then
Key := DecimalSeparator
else
Key := #0; // десятичный разделитель
else
key := #0;
end; // case
end;
end.
|