Recent

Author Topic: How to disable autoscroll in TRichMemo  (Read 381 times)

CM630

  • Hero Member
  • *****
  • Posts: 1642
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
How to disable autoscroll in TRichMemo
« on: October 29, 2025, 10:59:28 am »
Is there a way to disable autoscroll in TRichMemo?
This code works in TMemo, but does not in TRichMemo:

Code: Pascal  [Select][+][-]
  1.   try
  2.     {Rich}Memo1.Lines.BeginUpdate;
  3.     for i:=0 to 50 do
  4.       {Rich}Memo1.Append(IntToHex(i));
  5.   finally
  6.     {Rich}Memo1.Lines.EndUpdate;
  7.   end;  
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

CM630

  • Hero Member
  • *****
  • Posts: 1642
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: How to disable autoscroll in TRichMemo
« Reply #1 on: October 30, 2025, 09:00:11 am »
I have found a solution, but it only works when the vertical scrollbar is enabled; otherwise RichMemo1.VertScrollBar.Position; is always a zero. This post was helpful: https://forum.lazarus.freepascal.org/index.php?topic=65047.0

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   i: integer = 0;
  4.   v: integer = 0;
  5. begin
  6.   v := RichMemo1.VertScrollBar.Position;
  7.   RichMemo1.Lines.BeginUpdate;
  8.   for i:=0 to 50 do
  9.     RichMemo1.Append(IntToHex(i));
  10.   RichMemo1.ScrollBy(0,MaxInt);
  11.   RichMemo1.ScrollBy(0,-v);
  12.   RichMemo1.Lines.EndUpdate;
  13. end;
  14.  
« Last Edit: October 30, 2025, 09:03:23 am by CM630 »
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

 

TinyPortal © 2005-2018