WS_EX_COMPOSITED 从最小化状态恢复表单时导致无限重绘 [英] WS_EX_COMPOSITED causes endless repainting when restoring form from minimize state

查看:33
本文介绍了WS_EX_COMPOSITED 从最小化状态恢复表单时导致无限重绘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当从最小化状态恢复时,Form 需要无限的时间来重新绘制.
Form 是无边界的.我要覆盖 WndProcCreateParms.
我正在将无边框 Form 从最小化状态恢复到正常状态.
我正在重写 CreateParms 方法来放置阴影并停止闪烁.

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;
        }
    }

删除cp.ExStyle |= 0x02000000后问题消失,但出现闪烁问题.

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

添加似乎导致问题的自定义控件的代码:

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);
    }
}

推荐答案

我遇到了和你一样的问题,我解决了这个将表单设计中的 TrasnsparencyKey 从黑色更改为另一种颜色但不是黑色的问题,尝试一种你没有使用的颜色.

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.

这篇关于WS_EX_COMPOSITED 从最小化状态恢复表单时导致无限重绘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆