Link to home
Start Free TrialLog in
Avatar of nikez2k4
nikez2k4Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Minimise to System Tray not Taskbar as well.

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.
Avatar of e1v
e1v

You can set this.ShowInTaskbar = false
Avatar of nikez2k4

ASKER

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

        private void Form1_Resize(object sender, System.EventArgs e)
        {
            if (FormWindowState.Minimized == WindowState)
                Hide();
           
        }
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.
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;
            }
-
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial