Flickerfree graphics the easy way

My colleague Frits Ankersmit at Class-A just pointed me to a way to get flicker-free Windows applications in .NET for virtually free. Normally you would introduce a programmatic way to do double buffering, where you build the next image of a user drawn part of the window in memory. This requires quite a lot of coding and a (maybe considerable) amount of memory for a bitmap. The .NET Framework offers you to do all of this using memory from the videocard and handle all of the double buffering. Here's how:

Enter the following line in the constructor of your form that does some animated drawing:

base.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);

That's it. Have fun with it.

Comments

# Dennis van der Stelt said:

Wow, could it get ANY simpler with .NET!? :)

Not that I'll use it often, but this article at least is inserted into my memory space (using double buffering) for when I (or someone else) needs it.

maandag 22 augustus 2005 12:01
# Dennis van der Stelt said:

Hmmm, I'm not too shabby about adding the email link directly on the page, using "mailto: bla@bla.com".

You make it email address gatherings bots too easy :)

maandag 22 augustus 2005 12:02