在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
项目中碰到此问题,之前一直没留意,研究一番用上,以做备忘。参考其它解决方法,不尽完美,自试之,达到效果。 直上代码: 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; 效果如图示: |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论