The VI Setup options for
Show Front Panel When Called and
Close Afterwards if Originally Closed will only affect a VI when it is called as a subVI, not as the main VI. The same holds true when you build a VI into an executable.
You can make use of the
Close FP method to close your VI's front panel at any point in your program by following these steps:
- Place an Open VI Reference function on the block diagram. This function can be found in the functions palette by going to Programming » Application Control » Open VI Reference.
- Right-click the VI Path input and go to Create » Constant. Enter the name of this VI into the constant.
- Place an invoke node on the block diagram at the point in your program where you want the front panel to close. This function can be found in the functions palette be going to Programming » Application Control » Invoke Node.
- Wire the output of the Open VI Reference into the invoke node.
- Click the invoke node and select Front Panel » Close.
- Run your VI. When the program reached the invoke node, your VI will close. This will work the same way when your VI is built as an executable.
The following example shows this implementation with a button to trigger closing your front panel. The testclose.exe application in the attachments below shows this behavior in executable form.
Additional Information
For versions of LabVIEW before 7.0, you will need to use the
Quit LabVIEW function to make your executable's front panel programmatically close. This function is located in your functions palette under
Application Control. The disadvantage in this approach is that all LabVIEW executables that are open will close at the time this function is called.