[Lazarus] Smooth scrolling label (marquee)

Luca Olivetti luca at wetron.es
Tue Nov 10 12:30:19 CET 2015


in my current project, I need a marquee.
I adapted the component from here:


which is a descendant of a TCustomLabel using a timer to move the text 
I have several problems with it:

- it is very cpu intensive (I have to put it over a picture, so the 
invalidate will also force the repainting of the bitmap I guess)

- the minimum timer interval is 10ms, and even that it's not guaranteed 
(the resolution on windows is around 15ms and I got a very different 
speed of the label using 10ms under virtualized windows xp and a real 
windows 7 machine)

- with such a low value (10ms) sometimes the application gets bogged 
down, specifically it cannot process the modal dialog I use to shut down 
the application.

- I solved the flickering by setting DoubleBuffered to the containing 
widget (a TPageControl), but, again, I think that takes its toll on cpu 

I tried to use a thread (with synchronize) instead of a ttimer to obtain 
a lower interval, but that only compounds the problems.

For the time being, I'm using 50ms and change the number of pixels to 
change the speed, however if I scroll more than 2 pixels every 50ms the 
scrolling isn't smooth enough, but the required speed should be 6 or 7 
pixels, and that's very unpleasant to the eye.

Any suggestion?

Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007

More information about the Lazarus mailing list