Is it possible to disable animation when minimizing / restoring window?

前端 未结 1 1630
忘掉有多难
忘掉有多难 2021-01-13 15:01

When I click minimize button in my Windows Forms application, I don\'t want it to perform the classic Windows minimize animation (window going down to taskbar).

As f

相关标签:
1条回答
  • 2021-01-13 15:26

    This works, but it has an unpleasant side-effect on the taskbar button. I can't think of another way, animation isn't even accessible from SystemParametersInfo().

    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }
        protected override void WndProc(ref Message m) {
            // Catch WM_SYSCOMMAND, SC_MINIMIZE
            if (m.Msg == 0x112 && m.WParam.ToInt32() == 0xf020) {
                this.Hide();
                this.WindowState = FormWindowState.Minimized;
                this.BeginInvoke(new Action(() => this.Show()));
                return;
            }
            base.WndProc(ref m);
        }
    }
    

    Update: disabling animation on Aero is possible by pinvoking DwmSetWindowAttribute() with the DWMWA_TRANSITIONS_FORCEDISABLED attribute. See this answer.

    0 讨论(0)
提交回复
热议问题