Create a callback function for control you want to use to quit the program and call QuitUserInterface() under EVENT_COMMIT.
To create a callback for a control:
1. Double-click on the control in the UIR editor.
2. Enter a function name (make one up) in the box labeled Callback Function, and click OK.
3. Right-click on the control and select Generate Control Callback.
4. Right-click on the control and select View Control Callback.
5. Call QuitUserInterface() under EVENT_COMMIT.
To allow the X on the Windows titlebar to close the program, you need to edit the panel and assign the control to be the Close Control for the panel: in the UIR editor, select Edit >> Panel. Look for the control labeled Close Control.
When you initially create your program, you can generate
the callback code (including QuitUserInterface) automatically using the UIR editor.
1. Assign a callback function to the control (steps 1 & 2 above).
2. In the UIR editor, select Panel... from the Edit menu.
3. Use the control labeled Close Control to select the command button, then click OK.
4. From the Code menu, select Generate >> All Code.
5. In the box at the bottom, place a checkmark to the left of the control you want to use to close the application.
Look at just about any of the userint sample programs that ship with CVI to see how they use a close control (or Quit button). The sample programs are typically installed in c:\Program Files\National Instruments\MeasruementStudio\CVI\samples. Open any project in userint and look for a Quit button on the user interface. Right-click on Quit and select View Control Callback.