Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing NotifyIcon from the notification area

Is it possible to remove NotifyIcon from the notification area (system tray) when an app terminates abruptly?

if no, how can I remove it when the app runs for the next time?

like image 542
DelPhi Avatar asked Oct 04 '13 13:10

DelPhi


People also ask

How do I remove something from notification area?

To change how icons and notifications appearPress and hold or right-click any empty space on the taskbar and select Taskbar settings. Under Taskbar corner icons: Select On for any icons you want to see on the taskbar. Select Off for any icons you don't want to see on the taskbar.

How do I delete notification icons?

If your Samsung Galaxy smartphone runs Android 11 or 12, open the Settings app and head into the "Notifications" menu. Then, tap "Advanced settings" and toggle off the "App icon badges" switch.

How do I remove icons from the notification area in Windows 7?

Click Turn system icons on or off. For each system icon, select On to show the icon in the notification area, or click Off to remove the icon from the notification area. Note You can also select "Always show all icons and notifications on the taskbar" and "Restore default icon behaviors."


2 Answers

Abruptly? No. Your program has ceased to exist, so there's no opportunity to run any code to tell the shell that it should remove the icon.

To remove the icon, move your mouse over it. The shell will try to notify your program, realize there's nothing there anymore, and remove the icon by itself.

like image 134
Rob Kennedy Avatar answered Oct 12 '22 10:10

Rob Kennedy


On Windows 7 and later, notify icons can be identified by a user-defined GUID. On earlier versions, they are identified by a combination of HWND and ID number instead. Since your app is not guaranteed to get the same HWND value the next time it runs, the only way you can do anything to an old icon that is identified by HWND is if you remembered the previous HWND value so you can use it to remove the old icon, before then using a new HWND to add a new icon. But with a GUID-identified icon, the GUID needs to be persistent (as it is stored in the Registry to store app settings associated with the icon), so you should be able to simply keep updating the existing icon as needed, or remove it if desired.

like image 26
Remy Lebeau Avatar answered Oct 12 '22 09:10

Remy Lebeau