1

I have developed a windows application whose interface has a multiple text boxes and all of them are placed in one panel (the panel have a background image).

Whenever the panel is being loaded, the window(with these textboxes) is flickering.

I read a lot of suggestions to minimize this flickering, One of the suggested solutions was the following,

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

But it does not work with me,

I read about turning off the WS_CLIPCHILDREN using this code:

protected override CreateParams CreateParams {
  get {
    var parms = base.CreateParams;
    parms.Style &= ~0x02000000;  // Turn off WS_CLIPCHILDREN
    return parms;
  }
}

This code help some people who faced the same problem. So I want to use it but I really don't know where to paste it, I mean, I read that it should be pasted not in the form, but in the the UserControl's code. I don't know how to do that, all the controls that i used is not a custom controls.

Take a look here & see the 1st answer:

How to fix the flickering in User controls

Thanks in advance,

Community
  • 1
  • 1
user1477701
  • 147
  • 1
  • 5
  • 15
  • I don't get any flickering when my forms load. Are you sure you aren't doing a lot of unnecessary work in your UI thread during the loading process? – siride May 04 '13 at 17:04
  • Actually I have a panel which is invisible initially, when a user click on one button, this panel(along with the text boxes on it) will be visible, plus, all the text boxes will be filled. It is not that noticeable flickering. but it bothered a little. Thanks :) – user1477701 May 04 '13 at 17:20

2 Answers2

1

You might consider turning on WS_EX_COMPOSITED style also, it may help in some cases:

parms.ExStyle |= 0x02000000; //WS_EX_COMPOSITED
  • Thank you Todd,unfortunately turning this on does not make any difference, this is why I want to try the code in my ques,it may do something for me .. Thanks again. – user1477701 May 04 '13 at 22:17
0

Try deriving from Panel and setting DoubleBuffered() to True:

public class BufferedPanel : Panel
{
    public BufferedPanel()
    {
        this.DoubleBuffered = true;
    }
}

Then use that from your ToolBox instead of the default Panel.

Idle_Mind
  • 38,363
  • 3
  • 29
  • 40