I used this code to AutoSize a TMemo but you might be able to modify it for your needs. The problem I see is that TForm.Caption.Font is not effected by the TForm.Font. Maybe set the Font to default in the routine.
------------
function GetTextHeight(ACtrl: TControl): Integer;
var
C: TBitMap;
begin
Result:= -1;
C := TBitmap.Create;
try
C.Canvas.Font.Assign(ACtrl.Font);
Result:= C.Canvas.TextHeight('TextHeight');
finally
C.Free;
end;
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
var
H: Integer;
begin
H:= GetTextHeight(Memo1);
If H>-1 then
Memo1.Height:= (H*Memo1.Lines.Count)+H div 2;
end;
Bart wrote 15 lines
Shalom,
Avishai
????? ????