Symbian
Symbian OS Library

FAQ-1100 How do I prevent flicker in my application ?

[Index][spacer] [Previous] [Next]



 

Classification: C++ Category: Application Engines
Created: 07/27/2004 Modified: 08/05/2004
Number: FAQ-1100
Platform: Symbian OS v6.0, Symbian OS v6.1, Symbian OS v7.0, Symbian OS v7.0s, Symbian OS v8.0

Question:
What methods can I use to prevent flicker from happening in my application ?

Answer:
Every Cone control has a Draw() method and every pixel passed in to the Cone control must be filled by either the control or by any control that owns it. This "contract" must be kept otherwise there is a risk of the Draw() method being called by several controls.
    Here are some guidelines for avoiding flicker:
    • Make sure that there is no calculating done in the Draw() method, all data should be ready and in the correct format. Lengthy Draw() methods cause a flicker.
    • Avoid clearing the area then re-drawing. An example of this might be:
    Imagine a simple animation, a shrinking black square on a white background.One way to do this would be as follows: clear background,draw 10x10 square,clear background,draw 8x8 square
    A better way to do it would be:
    clear background,draw 10x10 square,draw white line around perimiter of square, resulting in 8x8 square
    • Avoid calling Draw() or DrawNow() too many times for the same control. An example of this might be:
    Imagine a listbox-type function like AddItemToListL(const TDesC& aItemLabel) that actually adds an item and redraws the list. The problem is when the code, for example, adds a few items to the list in a loop. You get horrible flicker as the control redraws several times.


    FAQ -0299 shows how to locate where these types of things might be happening in your code.