Ask the Expert

I'm getting a lot of flickering on my application

My current VB.NET project is MDI-based. When I jump between the child forms (via the standard Window List menu, for example), they flicker very badly -- I can see every textbox being drawn to the screen! Other Windows applications do not suffer from this, so why do VB.NET apps? Is it possible to prevent this?
The amount of flicker you get on an application is very much dependent on the kind of video hardware and driver software you've got running as well as the particular features of your application. However, I've found turning on the following control styles in the form's constructor really helps to reduce flicker:
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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: