LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I Control the Windows "Close" Button (Little Red "X")

Hi All,

 

Is there a way I can configure my VI to shut down in a controlled manner if the user clicks the little red "X" at the very top right of the LabVIEW program window (see attached jpg).

 

I would like to set my program up to shut down the com port and exit normally if someone clicks that button.

 

Any help would be greatly appreciated.

 

Thanks!

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
0 Kudos
Message 1 of 7
(13,144 Views)

Use the event structure and the panel close event. In this event you can terminate the vi in a proper manner before the window is closed.

 

Ben64

Message 2 of 7
(13,137 Views)

Use an event structure with an event configure to catch the...

 

<This VI>   Panel Close

 

event.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 7
(13,135 Views)

Remember to wire a True to the discard event node, otherwise the VI will close anyway before you've had an chance to let any of your shutdown code do its work.

Message 4 of 7
(13,126 Views)

More specifically, you should use the "panel close?" filtering event (note the question mark).

 

With this you can discard the event and do whatever is more appropriate for the shutdown instead.

Message 5 of 7
(13,105 Views)

Be aware that the Panel Close? event will capture the littel red X, but it will not capture the File - Exit or Ctrl-Q event.  To capture this, you need another event case for Application Instance Close? event.  Similary, you can wire a True to the Discard terminal to stop the closing.

- tbob

Inventor of the WORM Global
Message 6 of 7
(13,098 Views)

Thanks very much, all.  I will work on implimenting the event control ASAP.

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
0 Kudos
Message 7 of 7
(13,063 Views)