Habe keine bessere Idee, wuerde es aber so machen:
Delphi-Quellcode:
procedure AdjustTextSize(AControl: TEdit);
var
l: Integer;
begin
with TControlCanvas.Create do
try
Control := AControl;
Font.Assign(AControl.Font);
l := TextWidth(AControl.Text) + 16;
finally
Free;
end;
if (Length(AControl.Text) > 10) then
begin
if (l > AControl.Tag) and (l > AControl.Width) then
begin
AControl.Width := l;
AControl.Tag := AControl.Width;
end;
end;
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
AdjustTextSize(TEdit(Sender));
end;