procedure TForm1.Button1Click(Sender: TObject);var BitMap: TBitMap; X: Integer;begin BitMap:= TBitMap.Create; try with BitMap.Canvas do begin Font.Assign(Button1.Font); X:= TextWidth(Edit1.Text); end; Button1.Width:= X + 10; Button1.Caption:= Edit1.Text; finally BitMap.Free; end;end;