A Nice Scrolling Window

  • Thread starter Thread starter Ken Williams
  • Start date Start date
K

Ken Williams

Hi can anyone point me to some sample source code for a scrolling window.

What I want is a text window that monitors incoming data continuously, so it
has to hold say a couple of hundred lines then after that the early lines
need to erase as new data arrives.

The only way I have seen this done is by copying to a buffer, deleting the
first bit then putting it back in a text window.

It does work, but it causes the scroll bar to quickly jump, you don't often
see it, but it just doesn't seem very elegant, there must be a better way.

Ken
 
Ken,

Two fairly easy things I can think of with say a RichTextEdit window.
The lines property is basically an array of strings. Every time a line is
added to the window, you should make the newest line visible, that will
keep your smaller window view into the 200 lines always at the last entry.
Secondly, every time a couple of lines ares added and you are over 200,
delete just the first few. This should ensure that your scrollbar doesn't
jump arround too much. I have not tried this, and its possible that the
extra redraws you may see would also not be desirable.

Instead you could have a string [200] and once full you delete the first
to add a new at the end ie; remove mystrarr[0], add mystrarr[199]. Then in 1
shot you could set the editbox text to the contents of your string array-
thus only encurring one redraw.

Just some thoughts.


Erin.
 
Yes but it does make the scroll bar jump, when you delete the first line
and do a re draw the scroll bar starts at line one and follows the cursor.

It's a very fast jump, but it makes me think I must be using the wrong
approach.

Ken

EMonaco said:
Ken,

Two fairly easy things I can think of with say a RichTextEdit window.
The lines property is basically an array of strings. Every time a line is
added to the window, you should make the newest line visible, that will
keep your smaller window view into the 200 lines always at the last entry.
Secondly, every time a couple of lines ares added and you are over 200,
delete just the first few. This should ensure that your scrollbar doesn't
jump arround too much. I have not tried this, and its possible that the
extra redraws you may see would also not be desirable.

Instead you could have a string [200] and once full you delete the first
to add a new at the end ie; remove mystrarr[0], add mystrarr[199]. Then in 1
shot you could set the editbox text to the contents of your string array-
thus only encurring one redraw.

Just some thoughts.


Erin.


Ken Williams said:
Hi can anyone point me to some sample source code for a scrolling window.

What I want is a text window that monitors incoming data continuously,
so
it
has to hold say a couple of hundred lines then after that the early lines
need to erase as new data arrives.

The only way I have seen this done is by copying to a buffer, deleting the
first bit then putting it back in a text window.

It does work, but it causes the scroll bar to quickly jump, you don't often
see it, but it just doesn't seem very elegant, there must be a better way.

Ken
 
Back
Top