"Thomas Richter" wrote:
Hi,
I can't get of the black flicker when I resize my form.
this = Mainform : System.Windows.Forms.Form
If I set the size from 300 to 500 I see for ca 500ms some
black areas. I try to solve it with:
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
But it doesn't work.
That's because it doesn't do what you'd intuitively think it does.
What I assume you're thinking that does is the following
Create temp buffer.
Draw form and all controls in buffer
Copy buffer to screen
What's actaully happening is the following:
Create temp buffer
Draw form (without any controls) in buffer
Copy buffer to screen
Draw controls directly to screen
Unfortunately afaik there's no way to draw the form and all the controls it
contains in an offscreen buffer without writing all the paint code yourself.
If you're doing any manual resizing in the Resize or SizeChanged event
handlers try to reduce it as much as possible using anchoring and auto
resizing to do as much of the work as possible, it's much faster and
consequently smoother than trying to do the work yourself. In a recent
project I managed to work out ~80% (subjective) of the redraw flicker by
spending a day toying with the automatic resize functionality to reduce the
ammount of manual intervention needed.