Is it possible to disable animation while minimizing / restoring a window?

When I click the Minimize button in my Windows Forms application, I don’t want it to perform the classic Windows minimization animation (the window goes to the taskbar).

As far as I know, there is no Minimize event, I can just use Resize, but I don’t know how to determine if the button clicked to minimize the button. I tried to use if ( WindowState = FormWindowState.Minimized ) { ... }, but it is still animation and runs the code after.

Is there a way to detect a click on the minimize button? Is there a way to turn off the animation or is it called up by windows settings?

+3
source share
1 answer

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

: Aero , DwmSetWindowAttribute() DWMWA_TRANSITIONS_FORCEDISABLED. . .

+5

Source: https://habr.com/ru/post/1731035/


All Articles