Requires Free Membership to View
When you register, you'll begin receiving targeted emails from my team of award-winning writers. Our goal is to provide a unique online resource for developers, architects and development managers tasked with building and maintaining enterprise applications using Visual Basic, C# and the Microsoft .NET platform.
Hannah Smalltree, Editorial Director
public MyMdiChildFormM() {
InitializeComponent();
// Stop the flicker
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
}
The double buffering style causes the form to do all of the drawing into an off-screen buffer that's drawn to the screen all at once. The all painting in WM_PAINT style disables the normal erase phase of the drawing, making everything happen in a single drawing phase, further reducing flicker.
While double buffering (without the initial erasing of the background) can make all the difference in the user experience, double buffering requires the memory to capture the entire visible region at the current color quality. At 32 bits per pixel, a 200x200 region is 156 K in additional memory used per drawing operation for that region. In memory-constrained systems, this extra memory usage could degrade instead of improve the user experience.
This was first published in January 2003