Valhalla Legends Forums Archive | General Programming | Eliminating TextOut Flicker

AuthorMessageTime
Soul Taker
I have a timer I am drawing over a control using the TextOut API, so I redraw it every second. This causes things to flicker quite a bit, anyone know how to prevent this without drawing it in the background and then BitBlt-ing it into the right spot?
January 28, 2004, 8:58 AM
K
Ideally you should only draw when the region you're drawing to has been invalidated, unless you're drawing different text every second.

You could call LockWindowUpdate on the control's handle and then Unlock it after drawing. Optionally, to prevent desktop flicker, you would check if your program has focus, and not Lock/Unlock if it doesn't.
January 28, 2004, 6:06 PM
Soul Taker
[quote author=K link=board=5;threadid=4967;start=0#msg41508 date=1075313194]
Ideally you should only draw when the region you're drawing to has been invalidated, unless you're drawing different text every second.

You could call LockWindowUpdate on the control's handle and then Unlock it after drawing. Optionally, to prevent desktop flicker, you would check if your program has focus, and not Lock/Unlock if it doesn't.
[/quote]
Yes, it is a timer so the text is different each time, and I compare the string to the last drawn to make sure it's not drawing the same thing twice pointlessly in case the seconds de-synch. Locking the control during drawing works nicely!
January 28, 2004, 6:17 PM
Skywing
WM_SETREDRAW disables painting for a window. This doesn't have the nasty flicker problems associated with LockWindowUpdate, and you can do it to more than one window at once.
January 29, 2004, 4:03 AM
Adron
Still, from the description of LockWindowUpdate, I couldn't see that it was at all meaningful to draw with updates locked? You should just invalidaterect and let WM_PAINT do its thing naturally?
January 29, 2004, 9:38 AM

Search