autoscrolling memo in delphi

none picture none · Dec 1, 2010 · Viewed 27.9k times · Source

Does delphi contain a component that allows auto scroll text loaded from db, like in news sites?

Tt's for a delphi 7 application and requires a vertical scrolling.

Answer

vcldeveloper picture vcldeveloper · Dec 1, 2010

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:

procedure ScrollToLastLine(Memo: TMemo);
begin
  SendMessage(Memo.Handle, EM_LINESCROLL, 0,Memo.Lines.Count);
end;

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.