We help IT Professionals succeed at work.

Minimise to System Tray not Taskbar as well.

nikez2k4
nikez2k4 asked
on
Medium Priority
250 Views
Last Modified: 2010-04-16
Warning, c# N00b :-)

I'd like to minimise my app to the system tray, rather than the taskbar.
I've created a NotifyIcon and used the following code to hide the app from the taskbar:

  private void Form1_Resize(object sender, System.EventArgs e)
   {
   if (FormWindowState.Minimized == WindowState)
   Hide();
   }

The app when minimised goes to the system tray just fine but I still have the app on the taskbar too.
Everywhere I've hunted seems to show the same code to what I've already quoted - Am I missing something obvious?
Thanks,

- M.
Comment
Watch Question

e1v

Commented:
You can set this.ShowInTaskbar = false

Author

Commented:
Thanks for the reply... set it in .. here, or elsewhere?

        private void Form1_Resize(object sender, System.EventArgs e)
        {
            if (FormWindowState.Minimized == WindowState)
                Hide();
           
        }
e1v

Commented:
Hello, you could set ShowInTaskbar false when WindowState == Minimized and true when its not minimized.

But it shouldn't be necessary setting it at all... When I tried your Resize-method my program dissapeared form the taskbar just fine.
So there must be something else going on.

Author

Commented:
Went with this, which seems to work (not sure why the other one didnt)

-
  private void Form1_Resize(object sender, System.EventArgs e)
        {
            //Check to see if the window has been Minimized:
            if (this.WindowState == FormWindowState.Minimized)
            {
                //Remove the Program from the Task Bar:
                this.ShowInTaskbar = false;
                //Show the Icon in the system tray:
                notifyIcon1.Visible = true;
            }
-
Commented:
PAQed with points refunded (250)

GranMod
Community Support Moderator

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.