I got an animation on my form, which is done using the onpaint method and invalidate (with constant updating of the moving object's position ofcourse). Later on, i put a background image on the form and since then im having performance problems with my animation. If im not mistaken it's because invalidate keeps refreshing the whole form, which means the image aswell.Ive tried using a Graphics object and drawing on the form with it, but in this case i have to keep using the clear method in my animation, which makes the screen flicker.

Any help would be much appriciated

7 Years
Discussion Span
Last Post by Fandi_1

Ok, let me rephrase my question: is there any way to use the onpaint method and invalidate for my animation without refreshing the background image?


I have a project I downloaded from Code Project called fun with animation. It has 100 animations running on a background image with no flicker.
(animation.zip) is attached.
I think the key to it is under the InitializeComponents() method in the form constructor it has the following code. Maybe you can find what you need in the attached project. I use the concept in a mapping program and it works fine.

SetStyle(	ControlStyles.AllPaintingInWmPaint |
	ControlStyles.DoubleBuffer |
	ControlStyles.ResizeRedraw |
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.