[Lazarus] How to fix slow screen refresh of TListbox?

Bo Berglund bo.berglund at gmail.com
Sun Nov 20 22:59:02 CET 2022


On Sun, 20 Nov 2022 18:21:56 -0300, Flávio Etrusco via lazarus
<lazarus at lists.lazarus-ide.org> wrote:

>I see. My point is that you don't need to copy the whole DataBuffer and
>re-populate the whole SynEdit each time you receive new data. But this
>probably won't matter much unless you have hundreds of thousands of lines
>running on not so recent hardware.

Well, I tried at first to add incoming data to the bottom of the window, but it
turned out that when the transfer of data had been cut into parts by the serial
buffer such that the OnRxdata() triggered several times during the transfer then
the line at which the trigger happened was cut in two in the middle of the
screen.

Apparently the extra line break that was not part of the transfer was added by
the control when the data was added to the end. Next data added to it was not
adjacent to the last previous character but placed on the start of the next
line...

So the data in the synedit always ended with a linefeed even though there was
not yet any such in the transfered data.

Therefore I decided to use a dynamic TBytes array, which I could expand the size
of whenever the data arrived to fit the new packet and put it at the end of the
buffer.
Then I just replaced the strings in the display control with the full buffer
every time.
This way lines are not visibly cut in half or worse....

But it would be better if I could have kept the data in the SynEdit itself and
just expanded with new data as they arrived by putting them at the end...

Not so much to transfer then.
Just new arriving text.


-- 
Bo Berglund
Developer in Sweden



More information about the lazarus mailing list