From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Darren's Weekly Nugget 06/22/2009

Today's nugget deals with gracefully closing a LabVIEW built EXE window.  Most everybody knows the trick of using the Quit LabVIEW function at the end of a built EXE to close its window.  In fact, you may have even included some extra logic, like with a Conditional Disable Structure or the App.Kind property, to make sure Quit LabVIEW doesn't run while you're developing and debugging your VI in the LabVIEW editor:

 

quitLV.png

 

Have you ever noticed, though, that sometimes when you quit a LabVIEW built EXE, you see a brief flicker of the toolbar?   This can happen if you have your VI set to have a dialog window appearance (so that there is no toolbar), and you run the Quit LabVIEW function after clicking the "Stop" or "Exit" button that you created on your VI's front panel.  In this case, the built EXE, upon going idle, will show a toolbar (with the Run button) for an instant before the panel closes.

 

To avoid this toolbar flicker, you can make one simple change to the code above:

 

closeFPfirst.png

 

By calling FP.Close, you are telling LabVIEW to hide the front panel of the VI/EXE first before exiting.  This way the extra cleanup that LabVIEW must do can occur without the front panel of the built EXE showing, and we never see the toolbar flicker.

Message 1 of 31
(9,279 Views)

Darren,

 

Thank you very much for this new nugget. I noticed this undesirable flickering but never took the time to try to avoid it. Thanks to your nugget, all my future applications will now close gracefully !

 

Best regards

0 Kudos
Message 2 of 31
(9,197 Views)

Would this work as a sub-vi with, perhaps, an 'error in' to give data flow?

 

It would certainly be useful to put it in the user library or favourites palette to simply drop onto the block diagram instead of building it from scratch each time.

 

 

Regards,

Sebster.

0 Kudos
Message 3 of 31
(9,170 Views)

Sebster:  Yes, it will work, but you should clear the error before you execute the code. Furthermore you will need to get the reference to the calling VI (or the top level VI).

 

Darren: Thaks a lot for the hint, the FP.Close was really new to me. Maybe you adress the other side (splash screen while loading) in a further nugget.

 

Felix

Message 4 of 31
(9,150 Views)

I don't understand why someone would use the Quit LabVIEW function.

It seems to me, it is a brutal way to end your application.

I have never use it and have never, even think of using it.

0 Kudos
Message 5 of 31
(9,137 Views)

I use it in ALL my applications. As shown in Darren's example it is executed only when running an EXE.

 

Put this piece of code at the end of the main VI (the last operation just right before quitting the VI). Doing so, the EXE (App.Kind = Run Time System) will end without the need to manually close the FP of the main VI. In the other modes (eg Development System, Evaluation...), this code will not be executed and LabVIEW will not be closed.

Message Edité par JB le 06-23-2009 01:47 PM
Message 6 of 31
(9,114 Views)

Darren: Thanks a lot for the hint, the FP.Close was really new to me. Maybe you adress the other side (splash screen while loading) in a further nugget.

 

Felix


You might be interested to know that I have posted this request (easier way to implement a splash screen) to the LabVIEW Idea Exchange a few hours ago...

0 Kudos
Message 7 of 31
(9,104 Views)

JB wrote:

Put this piece of code at the end of the main VI (the last operation just right before quitting the VI). Doing so, the EXE (App.Kind = Run Time System) will end without the need to manually close the FP of the main VI.


Yes but if you close the front panel manually, the application will be terminated normally when it has finished all actions, in all vis.

If you use that, you will force everything to close. It is like pulling the plug of your computer...

I do not like it

 

0 Kudos
Message 8 of 31
(9,039 Views)

I just use the close front panel method of the main VI in my application and it shuts down LV runtime engine as well. Or it seems to be shut down.

Is there a difference?

 

Regards,

Jörn

0 Kudos
Message 9 of 31
(9,009 Views)
edited: mistake
Message Edited by ceties on 06-23-2009 03:46 PM
LV 2011, Win7
0 Kudos
Message 10 of 31
(9,001 Views)