The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Email Subscription

    Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 717 other subscribers

autoscrolling memo in delphi – Stack Overflow

Posted by jpluimers on 2013/04/03

Just found this great answer by vcldeveloper to autoscroll a readonly logging memo in Delphi which works from Delphi 1 and up (:

For such a simple task, you don’t need to buy a commercial component! All you need to do is to send an EM_LINESCROLL message to that memo control, to make it scroll to the last line:

[sourcecode language=”pascal”]
procedure ScrollToLastLine(Memo: TMemo);
begin
SendMessage(Memo.Handle, EM_LINESCROLL, 0,Memo.Lines.Count);
end;
[/sourcecode]

If your memo is read-only to users and is updated automatically by the application, you can put a call to the above procedure in its OnChange event-handler, so that whenever the text inside the memo is changed, it is automatically scrolled down to the last line.

–jeroen

via: autoscrolling memo in delphi – Stack Overflow.

9 Responses to “autoscrolling memo in delphi – Stack Overflow”

  1. Nice!

  2. Stefan's avatar

    Stefan said

    Does this not work for you, which also works for RichEditMemos etc?

    mLog.Perform(WM_VSCROLL, SB_BOTTOM, SB_THUMBTRACK);

  3. sckfjsdhfjk's avatar

    sckfjsdhfjk said

    i was wondering if there is a way to auto scroll the memo in a human reading pace?

    • sckfjsdhfjk's avatar

      sckfjsdhfjk said

      you can
      add a timer, that will scroll down by amount of lines each iteration, such as

      procedure TForm1.Timer1Timer(Sender: TObject);
      var
      amountOfLines:integer;
      begin
      amountOfLines:=5;
      SendMessage(Memo.Handle, EM_LINESCROLL, 0,amoutOfLines);
      end;

Leave a Comment