Eliminating flicker in GDI is “That Simple”
Wednesday 2 September 2009 - Filed under Uncategorized
A lot of developers have trouble making their Windows UIs not flicker. A lot of developers have also offered advice in various forms on how to fix the problem, which do (to an extent) tend to work, but usually miss the root of the problem.
There is, however, a single rule, which if followed, produces flicker-free rendering. Here:
You must paint each pixel in the invalidated region exactly once.
There’s no point in being prescriptive about double-buffering, or clever clip management, or extended window style bits, or any other specific techniques which will individually get you 90% the way there, since these are all just ways of following this rule. Here it is again, because it’s important:
You must paint each pixel in the invalidated region exactly once.
That’s all.
2009-09-02 » admin
2 September 2009 @ 4:09 pm
Yep – that’s very true. There is no other way.
We opted not to use the standard Windows controls or the standard Delphi controls in our application and implement our own set.
When painting, we add every area we paint actual pixels to an overarching tracking Region and then only erase the non-painted pixels by subtracting said Region from the Paint Rect.
Smooth and flicker free and as an unanticipated side benefit, it’s very TS friendly.
We had clients comment on how little bandwidth our application needed whilst offering nice interactive feel under TS back in the pre-jetstream days.
7 May 2010 @ 2:00 am
Internet Explorer 8 have been my most used browser this year, it is definitely stable and fast loading too. .*