procedure TForm1.BitBtn3Click(Sender: TObject);var c: TBitmap;begin c := TBitmap.Create; try c.Canvas.Font.Assign(Memo1.Font); Edit2.Caption := IntToStr(c.Canvas.TextHeight('My String')); finally c.Free; end;end;
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;
I tried Taaz's solution (from the other thread).
The thread quoted by Taazz in post 2 http://forum.lazarus.freepascal.org/index.php/topic,21305.msg124432.html#msg124432Maybe I should have said „topic‟.
...or you could look up how the label does it...