To download NI software, including the products shown below, visit ni.com/downloads.
Overview
Coding that exemplifies how to avoid closing the front panel by mistake.
Description
This example demonstrates two methods to protect your VI from being accidentally closed during execution.
Method 1:
The user can close a VI during execution by both selecting File » Close or clicking the close box in the title bar. Either of these actions will trigger the Panel Close? filter event, which will prompt a user dialog to confirm whether the user indeed wishes to close the VI during execution. If the user selects Yes, then the event is not discarded, and the panel will close. If the user selects No, then the event is discarded, and the code continues to run.
Method 2:
If the developer does not want the user to have the option of accessing either the File menu or the close box, then both the title bar and menu bar can be removed from the VI during execution. This can be accomplished both programmatically or via the VI Properties.
Programmatically:
Changing the value of the boolean toggle switch will trigger a Value Change event and either show or hide the title/menu bars.
VI Properties:
One can configure a VI to hide the title/menu bars during execution by navigating to File » VI Properties » Category: Window Appearance. Then select the Custom radio button and click Customize. Finally, deselect the Windows has title bar and Show menu bar boxes.
Requirements
LabVIEW 2012 (or compatible)
Steps to Implement or Execute Code
1. Run the VI
2. Change the control to show or hide the Title/Menu bar
3. Click on the red x in the upper right corner of the front panel
4. Select the desired option.
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.