Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatic scrolling in a Tmemo 1

Status
Not open for further replies.

aprobe

Programmer
Dec 4, 2003
36
NZ
I'm using a Tmemo to display the progress results of messages sent between a program I have written and the main server.

On a good connection when all things go well all the details are displayed on the viewable area of the memo. However, when things go wrong there are more messages than can be viewed on one screen. I have the component set up as enabled and read only with vertical scroll bars so the user can scroll down and see all the messages, however it is not obvious.

The cursor is always on the top line by default unless the user changes the position by moving down the memo or usng the scroll bars.

Is it possible in some way to control the cursor and automatically scroll the details displayed so the latest details are always visible.

 
A simple solution to this might be to always add a message as the first line in the memo. It would be a good idea to timestamp each line.

Your log might look like this
Code:
2003-12-18 09:12:01 Connection with server terminated 
2003-12-18 09:11:54 496 records read from server
2003-12-18 09:08:17 Connection with server established

However, when I have implemented this kind of message log in the past, I have used a TDrawGrid to display a log from a text file kept on disc. You can have a lot of control over the display of a TDrawGrid and having the log on disc is invaluable when trying to resolve problems after a crash.

Andrew
 
I'm actually sending http posts with embedded xml files. I always log everything to disk anyway so that's not a problem. Also, all good responses I receive back have a timestamp on them so that's no problem either. I don't really have enough real estate on the form to add date and time to each line, in my case that's overkill anyway because the user initiates the message and can see the response straight away.

The problem is simply when the visible area of the memo is filled it's not obvious that it's still going on beyond the bottom of the viewable area.

I have also tried adding it to the front of the memo each time. It would come out in the order you showed, however it's just doesn't look right. It's not logical, you are used to reading down and it's strange for the latest line to be at the top !

I haven't looked at TDrawGrid though. I will take a look at this and see if this helps.

Thanks
[pipe]
Brian

 
Try something like this:

MyMemo.SelLength := 0;
MyMemo.SelStart := length(MyMemo.Lines.Text);

This will move the cursor to the end of the last line. I'm not entirely sure whether it will "scroll" the memo, though.

-D
 
Oops! Actually it's:

MyMemo.SelStart := length(MyMemo.Text);

-D
 
Thanks Hilfy

I tried it but it still continues to build up beyond the bottom of the viewable area of the memo.

 
I've changed the component to a TStringGrid and can control the viewable area using the TopRow property.

Thanks Guys [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top