type TMemo = class(StdCtrls.TMemo) protected procedure Change; override; end;
{ TMemo } procedure TMemo.Change; var lc, lh: Integer; cvs: TControlCanvas; begin inherited; cvs := TControlCanvas.Create; try cvs.Control := Self; cvs.Font.Assign(Font); lh := cvs.TextHeight('z') + 2; finally cvs.Free; end; lc := Lines.Count; if (Text <> '') and (Text[Length(Text)] = #10) then Inc(lc); if lc * lh > Height then begin if ScrollBars = ssNone then begin ScrollBars := ssVertical; Perform(WM_VSCROLL, SB_BOTTOM, 0); end; end else if ScrollBars = ssVertical then ScrollBars := ssNone; end;