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.
Advertisements