Si me permites "pachotear" en cierta forma tu codigo, al final esta sería una versión funcional, que solo adapta lo anteriormente dicho por mi, pero a tu propio codigo
:
Código Delphi
[-]
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var sNumAnterior:string;
begin
sNumAnterior := (sender as TEdit).Text;
if (key <> #3) and (key <> #22) then begin if key in ['-',DecimalSeparator] then
begin
if (pos(key,(sender as TEdit).Text) > 0) and
(pos(key,(sender as TEdit).SelText) = 0)
then key:=#0;
if key ='-' then
begin
if ((sender as TEdit).SelStart > 0) then key:=#0;
end
else
begin
if key = DecimalSeparator then
begin
if ((sender as TEdit).SelStart = 0) or
(((sender as TEdit).SelStart = 1) and
((sender as TEdit).Text[1] = '-'))
then key:=#0;
end;
end;
end
else if not (key in ['0'..'9',#8]) then key:=#0;
end;
if key = #22 then
try
key := #0;
(sender as TEdit).PasteFromClipBoard;
StrToFloat((sender as TEdit).Text);
except
(sender as TEdit).Text := sNumAnterior;
(sender as TEdit).SelStart := Length((sender as TEdit).Text);
end;
end;
Espero que esto te ayude.