2

I have an application in which I can move from 1 user control to many user controls. When I was moving to many controls, I was getting flickering issues. To solve the flickering I enabled Double Buffering via -

protected override CreateParams CreateParams
{
    get
    {
        CreateParams cp = base.CreateParams;
        cp.ExStyle |= 0x02000000;  // Turn on WS_EX_COMPOSITED
        return cp;
    }
}

It indeed solved the issue of flickering. But introduced a new problem, In which sometimes my user control isn't painted completely. A black window is appeared. To solve this, I need to minimize and maximize the software and it appears properly.

What I think is that, while double buffering is painting all the user controls at one shot, One or more user control is still generating its controls. And at the time of master painting, that control was not ready.

Here is the image for getting proper idea -

enter image description here

As shown in image, There is one form, containing 4 user controls in this particular scenario. Each user control further, contains other controls/user controls.

What is probably going wrong in this issue?

Arpit Gupta
  • 1,209
  • 1
  • 22
  • 39
  • Have you tried calling `Invalidate()` in `ResizeEnd` event? – Sandeep May 09 '18 at 07:13
  • @Sandeep No man, it wasn't helpful. – Arpit Gupta May 09 '18 at 11:25
  • Got similar issue but for little less complicated user controls. This issue was resolved by calling `Invalidate()` in `ResizeEvent` to handle main window movement. And by calling `Invalidate` in `MouseUp` event for user control movement. – Sandeep May 09 '18 at 12:22

1 Answers1

0

I solved this by changing TrasnsparencyKey in form design from black to another color but not black, try one color that you are not using.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135