-1

I want a notifyIcon for my windows form application with click functions like taskbar button :

  • When the form is on top of other applications; activated, clicking on the notifyIcon must minimize application's window.
  • When the form is under other applications; deactivated, but not minimized, clicking on notifyIcon must activate application's window.
  • When application is minimized, clicking on the notifyIcon must maximize application's windows.

I've already tried Deactivate event of the form and Click event of notifyIcon, but it seems that in C# Deactivate event of form is compiled before Click event of the notifyIcon.

Here I found a way to detect if application is activated by clicking in the taskbar, but I couldn't find the same way for deactivation.

Community
  • 1
  • 1
mrmowji
  • 934
  • 8
  • 29

1 Answers1

0

Try this..

private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
    {
        if (this.WindowState == FormWindowState.Minimized) 
        { 
            this.Show(); 
            this.WindowState = FormWindowState.Normal; 
        }
        else 
        {
            this.WindowState = FormWindowState.Minimized; 
            this.Hide(); 
        }
        this.Activate();
    }

This is a notifyIcon DoubleClick event.

Krishna Thota
  • 6,646
  • 14
  • 54
  • 79