0

I know it's a "feature" of using debug that systray icons do not get removed on [STOP] when debugging in Visual Studio Express 2013 C# but is there a convincing way to remove a system tray icon on frmMain_load so that debug routines once stopped are removed at next pass (and therefore the problem is tailored for)

user26676
  • 280
  • 3
  • 21

1 Answers1

1

If a process is stopped abruptly without removing a notification icon, the notification icon will remain until the next time the system attempts to interact with it. At that point is discovers that the window associated with the icon no longer exists, and it removes the icon from the notification area.

There's no programmatic way to force this removal. Not least because there's no longer a window available by which you can identify the icon. The standard way to get rid of them is to wave the mouse cursor over the orphaned icons and then let the system remove them.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • yes I know the "standard way" but it's really lame lol .. I was thinking there might be a `programmatic way` to touch them, or maybe a way to loop through all of the displayed icons and look for (and delete) any occurrence of the icon *I use*.. seems odd there in "no way" to do this – user26676 Jul 15 '14 at 14:56
  • is there a way to get windows to do a refresh or maybe an "on exit" command that works even when you stop a debugger? – user26676 Jul 15 '14 at 14:57
  • Comment 1: That's just how it is, whether you like it or not. MS presumably decided that there was no need to design for programs that forgot to remove icons, nor for programs that were closed abruptly. Comment 2: Perhaps it depends on your debugger. I've never encountered one that will let you run code when you terminate a process. Again, there's no practical use for such a feature so it's very hard to imagine any debugger author ever added such a feature. – David Heffernan Jul 15 '14 at 14:57
  • David look at this.. http://stackoverflow.com/questions/74723/can-you-send-a-signal-to-windows-explorer-to-make-it-refresh-the-systray-icons?rq=1 – user26676 Jul 15 '14 at 15:00
  • @user26676 Faking input to make the system think you moused over the notification area would indeed get the job done. Rather amazingly all the answers there appear to be answering the question you asked here, but not answering the question that was actually asked there! – David Heffernan Jul 15 '14 at 15:02
  • I can't make head nor tail of their code and the link is broken - oh well :-/ – user26676 Jul 15 '14 at 15:05