07-02-2010 08:01 AM - edited 07-02-2010 08:01 AM
I know how to create a system tray icon for my application using InstallSysTrayIcon().
I also know how to remove it before the program terminates (calling RemoveSysTrayIcon()).
But the program closes in an expected way, or through the Task Manager, for example, the icon isn't deleted, and the user could think that the application is still running. Moreover, when you re-launch the application, a second icon is shown.
The Windows OS removes the orphaned icon when the mouse hovers over the tray.
It seems that this is an OS issue, and I did some web searches: I found this describing a way to avoid this behaviour in a C# application, but I haven't been able to port this solution to a CVI application.
Is there a way to do this with CVI 2009?
07-06-2010 10:54 AM
Hi Vix,
I saw the solution offered by the link you posted and I think but I'm not sure about it, that we can't adapt that solution to CVI because .NET is a different framework with different events and APIs.
I tried myself to develop a solution and I saw that when we close the program from the task manager (force close), no event is generated inside the CVI program so we can not handle any event as the C# developer could do.
Anyway if you're worried about program crashes your only option, I know that I'm not saying nothing very smart, would be to increase the error handling and exception catching in order to avoid the crashes and if it is unavoidable, you may call a function which can handle the system tray icon elimination.
Let's see if some more skilled developers can help about this or give some more suggestions.
Best Regards
07-07-2010 01:36 AM
Hi Luca!
Anyway if you're worried about program crashes your only option...
Actually what I'm worried about is a little bit more complicated: my CVI application could be remotely closed by other applications running on the same or other PCs on the LAN. I should avoid the icon is left on the system tray while the application has been closed, giving a wrong information to the user...
I've been using the task manager only to "simulate" a force close made by a different application.
And sure, I must increase the error handling as much as I can to avoid application crash ![]()
07-07-2010 05:05 AM
Hi vix, I was looking a way in the past to trap system closing while my application is running (you know: the user pressing PC power button when it's set as "shutdown machine"): I was pointed to several messages a CVI application can receive in that case, that could be recevied also in your situation. Take a look at the threads listed here.
I hope all this may help.