Click here to Skip to main content
15,904,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have created an MFC application and this application runs in the system tray. Once the work is done with this particular application i am killing the process using another MFC application.Now the problem i am facing here is even after the application is terminated the icon is still visible in the system tray and those icons are not cleared until i move my mouse on the tray.

Thanks in Advance
Posted

Rather than kill the process externally, set it up so that you can send it a message, and send a "please terminate" message so that it can clean things up and terminate itself gracefully.
 
Share this answer
 
Comments
Rocky_Bas 4-May-13 0:45am    
But i can't manually terminate this application,as this application runs in the background and cant be opened.So i have to terminate it through other application once the work is done with that application.
H.Brydon 4-May-13 0:50am    
This statement makes no sense. Being a background process does not change anything. If it is a process on the system, you can send it a message. The concept of "background process" does not exist as a formal definition on any Windows platform.
C#
NOTIFYICONDATA nid={0};
nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hWnd = hWnd;
nid.uID = 1; //your num
Shell_NotifyIcon( NIM_DELETE, &nid);
 
Share this answer
 
Hi
You can do it with ::Shell_NotifyIcon(NIM_REMOVE, &address_of_oldicon); just for getting more information about it you can search in google.com I am sure this key word can be useful for you ;) Additionally please review follow of links:

Basic use of Shell_NotifyIcon in Win32[^]
Adding Icons to the System Tray[^]
http://msgroups.net/microsoft.public.vc.mfc/refresh-system-tray/547778[^]

Best Regards.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900