HmH
HmH

Reputation: 399

WS_EX_COMPOSITED causes endless repainting when restoring form from minimize state

The Form takes endless time to repaint when restoring from minimize state.
The Form is borderless. I'm overriding WndProc and CreateParms.
I'm restoring the borderless Form from minimized state to normal state.
I'm Overriding CreateParms method to drop shadow and stop flickering.

protected override CreateParams CreateParams
    {
        get
        {
            CreateParams cp = base.CreateParams;

            m_aeroEnabled = CheckAeroEnabled();
            if (!m_aeroEnabled)
               cp.ClassStyle |= CS_DROPSHADOW;

            cp.Style |= WS_MINIMIZEBOX;             
            cp.ExStyle |= 0x02000000; //WS_EX_COMPOSITED                
            cp.ClassStyle |= CS_DBLCLKS;

            return cp;
        }
    }

The problem disappears when removing cp.ExStyle |= 0x02000000 but then there is a flickering problem.

Edit: Adding the code of the custom control that seems is causing the problem:

public partial class BorderPanel : Panel
{
    public BorderPanel()
    {

    }

    protected override void OnPaint(PaintEventArgs pe)
    {
        ControlPaint.DrawBorder(pe.Graphics, this.ClientRectangle, 
           BorderColor, borderSize.Left, ButtonBorderStyle.Solid,
           BorderColor, borderSize.Top, ButtonBorderStyle.Solid, 
           BorderColor, borderSize.Right, ButtonBorderStyle.Solid, 
           BorderColor, borderSize.Bottom, ButtonBorderStyle.Solid);

        base.OnPaint(pe);
    }
}

Upvotes: 2

Views: 959

Answers (1)

I had the same problem like you and i solved this changing TrasnsparencyKey in form design from black to another color but not black, try one color that you are not using.

Upvotes: 2

Related Questions