LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using notifyicon in an executable shuts down application

Has anyone tried creating an exe using the notifyicon example on NI website (http://zone.ni.com/devzone/cda/epd/p/id/3915#0requirements)? 
I have an application in which I want to utilize an icon for viewing the panel, etc..  I followed their example, but when select the option to show the front panel (after I already slected the same to hide the front panel) the application crashes.
I tried compiling the NI example from above, and their program will actually shut down (it shoudn't).
Everything works fine if you are running from Labview source code (not an exe)
I am using LabVIEW 8.0.
Thanks.
0 Kudos
Message 1 of 12
(3,994 Views)

Inside the Create Icon subvi, there are Strip Path functions.  Works fine when running as a vi.  But when you compile into an exe, and extra path is added.  Then the strip paths do not strip down far enough.  For example:

Vi path is C:\My Projects\Labview\MyVI.vi

Current vi's path is C:\My Projects\Labview.  If you stip path once you get C:\My Projects

Now when you compile into an exe you get C:\My Projects\Labview\MyVI.exe.  MyVI.exe is considered part of the path.  So the current vi's path now becomes

C:\My Projects\Labview\MyVI.exe.  If you strip path once you get C:\My Projects\Labview.  You would need an extra strip path to get to the same level as when the vi is run in Labview, not as an exe.  So now the program is at the wrong directory level to change icons.  This might be why you get a crash.

I hope this is clear.  We have a function that was created to strip path depending on if the application is a vi or exe.  If exe, it strips path twice instead of once.

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 12
(3,982 Views)
In my application I actually account for that.  I read the "application kind" property to determine what system I am running from (run time or development), then strip the paths accordingly.
However, I did not account for this in NI's example, so I will rebuild their's and see what happens.
Thanks.
Message 3 of 12
(3,978 Views)
I ran the NI example a few times, and in one instance it shutdown labview.  Must be a bug or race condition in there somewhere.  Just don't have the time to look into it further.  I suspect it has something to do with the .NET framework.  Maybe some version incompatibility.
- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 12
(3,969 Views)
I tried the example on my machine, which is running Windows XP with LabVIEW 8.2 and .NET 2.0. The example ran just fine both in the development environment as well as a built application. I did have to copy the "Icons" folder to the folder where the application was, but that's about it.
0 Kudos
Message 5 of 12
(3,958 Views)

I tried building this with 8.2 and still have the same problem.  I am also using Win XP with .net 2.0. 

Let me explain what I am seeing in more detail....

The executable runs OK, but when you right click the icon on the tray and select "show front panel" a pop-up appears that said you did something, but when you click OK (on the pop-up) the entire program ends...  All the other selections, user, vis in memory, etc. work fine, its just the "show front panel" selection that causes the app to quit.

In my application the program doesn't end, the icon disappears, then my cmu performance goes to 100%, afterwhich I need to end the app. with Task Manager, but I think this is somehow related to what the NI example is doing (they both show/hide the front panel the same way).

0 Kudos
Message 6 of 12
(3,952 Views)
thats cpu performance, not cmu... 
0 Kudos
Message 7 of 12
(3,950 Views)
Well, I reran the NI example as an application and did as you said. I right-clicked on the icon in the tray and select the "Show Front Panel" menu item. The application closed. Of course, this was not surprising since that's the way the code is written. Selecting that menu item launches a callback which... closes the front panel. With an application, that effectively quits the application. I don't believe this example was intended to be used in this manner. In the development environment you don't see this behavior since in the development environment closing the front panel does not stop the VI running.

I did not experience the behavior you then saw. It took about 2 seconds, but the icon in the tray disappeared soon after the application quit, as this was the time it took the run-time engine to shut down. Task Manager never showed the CPU going nuts.

If, for you it's going nuts, then simply don't provide that menu item. As I indicated, I believe the example, as coded was intended to run in the development environment.
0 Kudos
Message 8 of 12
(3,937 Views)

tbob,

Can you pl post that NI example saved for LV 7.1 ?

I dont ve 8.0 or upwards. Smiley Sad

Will it run in 7.1 ? Should I ve .NET also installed in my system ?

Can you explain me in more detail ?

- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 9 of 12
(3,933 Views)
Ahhh, now I understand what is going on...  I may be able to make this work by pushing the front panel "off screen" or something...
Thanks for the help.
0 Kudos
Message 10 of 12
(3,928 Views)