• WinFom解决最小化最大化后重绘窗口造成闪烁的问题


    网上两种方案(可协同)

    1 设置双缓冲:


    SetStyle(ControlStyles.UserPaint, true);
    SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
    SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲

    2 捕获最大化最小化事件,临时挂起布局逻辑

    const int WM_SYSCOMMAND = 0x112;
    const int SC_CLOSE = 0xF060;
    const int SC_MINIMIZE = 0xF020;
    const int SC_MAXIMIZE = 0xF030;
    protected override void WndProc(ref Message m)
    {
    if (m.Msg == WM_SYSCOMMAND)
    {
    if (m.WParam.ToInt32() == SC_MINIMIZE) //是否点击最小化
    {

    this.SuspendLayout();
    this.WindowState = FormWindowState.Minimized;
    this.ResumeLayout(false);
    }


    if (m.WParam.ToInt32() == SC_MAXIMIZE)
    {
    this.SuspendLayout();
    this.WindowState = FormWindowState.Maximized;
    this.ResumeLayout(false);
    }

    if (m.WParam.ToInt32() == SC_CLOSE)
    { //.....................
    }


    }
    base.WndProc(ref m);
    }

  • 相关阅读:
    codevs1004 四子连棋
    codevs1009 产生数
    NOIP2014 寻找道路
    Tyvj1139 向远方奔跑(APIO 2009 抢掠计划)
    随机算法
    线性基
    线性基入门
    线性基 + 并查集
    欧拉公式 (平面)
    卡特兰数 + 大数
  • 原文地址:https://www.cnblogs.com/swobble/p/7474072.html
Copyright © 2020-2023  润新知