As part of an Excel add-in I am developing, I have a custom taskpane. In the taskpane I have a couple of panels that works as 'pages' for my taskpane and on top of these panels i have a lot of controls that are dynamically updated.
To avoid flickering I have overriden the createparams by pasting the follwing code into UserControl that defines my task pane.
protected override CreateParams CreateParams
{
get
{
const int WS_EX_COMPOSITED = 0x02000000;
var cp = base.CreateParams;
cp.ExStyle |= WS_EX_COMPOSITED;
return cp;
}
}
Everything work flawless except for the first time the taskpane is shown. Here the background of the visible panel flashes as one big black rectangle spanning the whole taskpane. How can I avoid this? One interesting case is, that if I do not override CreateParams the black rectangle does not flicker. But in this case, all other controls flickers, when the panel is updated.
I am pretty new at WinForms, so I migth completely miss the point on something fundamental. Am I suppose to only override CreateParams on the panels, and not on the whole taskpane. If so, how do I go around doing just that?