Closing a LabWindows™/CVI™ Application by Clicking the X Button in the Title Bar

Updated Dec 11, 2023

When running a LabWindows/CVI application, I would like to be able close the application by clicking the X button in the upper right-hand corner of the title bar. How can I do this?

In order for a LabWindows/CVI user application to close properly (rather than aborting the application) you must call the function:
To enable the X button to close the LabWindows/CVI application properly, you have two options:

If you are already using that function in a callback, you can point the panel to execute that callback function when the user clicks the X button. Open the User Interface Editor and double-click on the panel to open the Edit Panel dialog box. In this dialog box, set the Close Control setting to the control on your panel that causes the panel to close (i.e. the control with a callback function that contains the QuitUserInterface function).

In the example image above, you would need to implement a callback function for the control with the constant name QUIT. In that callback function, you would need to call the function QuitUserInterface in the EVENT_COMMIT case.
The other option is to create a panel callback function that captures the EVENT_CLOSE event. To create this callback, complete the following steps. 
  1. Double-click on the panel to open the Edit Panel dialog box
  2. Enter a callback function name in the Callback function property, such as panelCallback. Click OK.
  3. Navigate to Code >> Preferences >> Default Events and ensure that EVENT_CLOSE is checked for Panel. Click OK.
  4. Select Code >> Generate >> Panel Callback to generate the event callback function for the panel.
In the code for the EVENT_CLOSE event, you can perform any shutdown operations that are required by your application, such as closing references. Add a function call to the QuitUserInterface function to cause the application to close.