LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

When a application built using Application Builder is closed using the "X" button, the app quits before the code finishes

When the user clicks the "X" button (upper right corner), I wish to do a final cleanup before exiting.

I do this by checking the FP.Open property of the VI. If this becomes False, I stop the While loop, clean up and exit. This works fine in the development system, but when I build an app using Application Builder, the app just aborts instead of running the final code.

I have attached a simple VI and its built executable to illustrate the problem.
Download All
0 Kudos
Message 1 of 5
(2,858 Views)
I would recomend that you use the event structure to capture the Application Exiting event. There's an example called Event Conditional Stop that demonstrates how it's done.
0 Kudos
Message 2 of 5
(2,858 Views)
I have investigated your suggestion (see also this example), and although it is probably a good idea, event-driven programming is available only in the LabVIEW Full and Professional Development Systems (quoting the LabView User Manual). So, since I have just the Base Development System, I have to find another way. But thank you for your input.
0 Kudos
Message 3 of 5
(2,858 Views)
Hi Martin,

this is a build in behaviuor but there is a workaround for it.
In VI properties >> windows appearance >> custom uncheck "Allow user to close window". Put a stop button on the front panel. Instead of checking the FP.Open property read out the stop button terminal. Invert the logic because you now get a TRUE when you want to stop.

Waldemar
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 4 of 5
(2,858 Views)
I have already considered the option tha Waldemar suggested (thanks for your input), but since I would like my users to take advantage of their "Windows intuition" (*chill*), I would like the X to be present. However, I found another workaround which better mimics the behaviour I wanted. Since others might be interested, I post the solution here.

The workaround is to make your main VI a subVI of a "dummy" VI. This VI first hides itself (I achieved this by moving the panel off-screen; if I set FP.Open to False it doesn't work). Then I run the real main VI as a normal subVI, wait for it to close, and finally the dummy closes. To prevent the dummy from appearing in the Windows Taskbar, I unset "Allow User to Minimize Window" in File -> VI
Properties -> Window Appearance -> Customize.

I attach VIs to illustrate the solution.

Martin
0 Kudos
Message 5 of 5
(2,858 Views)