Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Remove the icon from the system tray programmatically
 

Remove the icon from the system tray programmatically

Hi,

i am developing an application using VC++2005. The application initializes itself and runs from the system tray. i am using the NotifyIcon to display my icon in the system tray.

The application has a requirement wherein if the application is not properly initialized it must terminate itself.

The application does terminate itself successfully but the icon in the system tray is not removed. The icon stays displayed. If I hover the mouse over it, it dissappears.

I want to remove the icon from the system tray programmatically.

thanx in advance!

rumDeep  Monday, May 05, 2008 12:18 PM

Hi RumDeep,

Based on my experience, there is a known issue about Windows’s System Tray which points out that icon may not disappear accordingly after application exists.

Anyway, as far as I know, this problem does not always happen.

For more discussion about this problem, please refer to the following thread, and hope nobugz’s answer may help you:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1925345&SiteID=1

Thanks.

Best wishes,

Jun Wang

Jun Wang Tim  Friday, May 09, 2008 10:50 AM
Hi,

I used a round-about solution for this issue.

In the constructor of my form, if i find that there has been an error I set the Visible property of the NotifyIcon to false.

Similarly in the Form load event, to be sure,I have set the Visible property to true.

Thanks,
rumDeep
  • Marked As Answer byrumDeep Tuesday, March 17, 2009 2:16 PM
  •  
rumDeep  Tuesday, March 17, 2009 1:18 PM

If you gracefully close your application the icon should go away correctly. How do you close it?

Mattias Sjögren  Monday, May 05, 2008 2:19 PM

Hi,

i have tried all the options that i know for gracefully closing the application. i had thought that doing so should remove the icon as it happens when we end the application.

i used

1. Close() ;

2. Application::Exit()

3. i also invoked the form_closing event.

but all of my options simply just dont work.

i have run out of options from my side. i'd appreciate any input on being able to remove the icon.

Thanks.

rumDeep  Tuesday, May 06, 2008 5:59 AM
it's just a screen refresh issue, your task has exited, hover your mouse over the icon and it will disappear, perhaps there is an api call to refresh system tray?

ntsmith  Tuesday, May 06, 2008 2:24 PM

Hi RumDeep,

Based on my experience, there is a known issue about Windows’s System Tray which points out that icon may not disappear accordingly after application exists.

Anyway, as far as I know, this problem does not always happen.

For more discussion about this problem, please refer to the following thread, and hope nobugz’s answer may help you:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1925345&SiteID=1

Thanks.

Best wishes,

Jun Wang

Jun Wang Tim  Friday, May 09, 2008 10:50 AM
You can use this excellent small tool: closeApp.exe
http://cleansofts.org/download/closeapp.html

Butch
ButchButch  Thursday, December 25, 2008 3:48 PM
Hi,

I used a round-about solution for this issue.

In the constructor of my form, if i find that there has been an error I set the Visible property of the NotifyIcon to false.

Similarly in the Form load event, to be sure,I have set the Visible property to true.

Thanks,
rumDeep
  • Marked As Answer byrumDeep Tuesday, March 17, 2009 2:16 PM
  •  
rumDeep  Tuesday, March 17, 2009 1:18 PM

You can use google to search for other answers

Custom Search

More Threads

• How to use Toolstrip control in C#.Net?
• TabControl - Selecting Tab in Code problem
• Compiler error
• Click once deployment - application data files path
• How to read the Code Generator statements of the Parent form using CodeDomSerializer class for a control
• Opening a form in design view causes a CC checkout
• Weird behavior when customizing property grid.
• UserControl's child container's contents not being serialized
• Previously visible user control becomes invisible in design view of winform(vb.net) in VS 2008.
• Custom MainMenu control positioning