Hello,

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

Recommended Answers

All 6 Replies

Are you using double buffering ?

Yes i am

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 |
	ControlStyles.UserPaint,
	true);

I managed to get it to work, thanks for your help

Its work... Thanks a lot bro...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.