Search code examples
c#.netformswindows-xpeffects

Change Minimizing Visual Effect


I've created an app with invisible form. (Opacity = 0 or Visible = false ShowInTaskbar = false) I've tried a lot of different ways of activating my form while having active other applications. By "activating" I mean giving focus to it without making it visible. For some reason, Activate() and Focus() methods are not working as supposed. According to MSDN (https://msdn.microsoft.com/en-us/library/system.windows.forms.form.activate%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396) Activate() method should cause focus of window if form is not minimized, but it is not working.

The only way I found to activate (focus) my window is minimize it and then return its state to Normal. It is working just perfect, but there is another problem: for Windows XP it causes constant effect of minimizing and maximizing of window, even though it is invisible. Is there a way to make this effect not visible just for my form?

Right now this effect is looking like this:

Effect


Solution

  • Ok, I managed to find answer to my question, very similar question has already been on Stack Overflow, my fault: Is it possible to disable animation when minimizing / restoring window?

    To be short, you just need to catch minimization system message in following way:

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