Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

autoscrolling memo in delphi

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.

like image 597
none Avatar asked Dec 01 '10 09:12

none


4 Answers

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.

like image 185
vcldeveloper Avatar answered Nov 15 '22 19:11

vcldeveloper


You can also use Memo.GoToTextEnd; when needed, for example inside an onchange event. Is not a proper auto-scrolling effect but can be useful in similar situations.

like image 31
LLuca Avatar answered Nov 15 '22 21:11

LLuca


None of those solutions for scrolling worked for me in the RichEdit memo. Using Delphi 2010 + w7. But this one works perfectly:

After every Lines.Add('...') this follows:

SendMessage(RichEditMemo.Handle, WM_VSCROLL, SB_LINEDOWN, 0);

Found in: http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_10120212.html

like image 35
Aljaz - aly Avatar answered Nov 15 '22 21:11

Aljaz - aly


Possibly, to save you some money you could adapt this to scroll a DBMemo:

EchoMemo.Lines.Add('A Line of text or more');
EchoMemo.SelStart := EchoMemo.GetTextLen;
EchoMemo.SelLength := 0;
EchoMemo.ScrollBy(0, EchoMemo.Lines.Count);
EchoMemo.Refresh;

I use for a log display.

like image 42
Despatcher Avatar answered Nov 15 '22 21:11

Despatcher