• Welcome to Valhalla Legends Archive.
 

Eliminating TextOut Flicker

Started by Soul Taker, January 28, 2004, 02:58 AM

Previous topic - Next topic

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?

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.

Soul Taker

Quote from: K on January 28, 2004, 12:06 PM
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.
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!

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.

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?