Published October 9, 2015
So have you even been working on a VI that is set as a modal window (or dialog window) that is called from your main LabVIEW application and forgotten to close it before running the top-level VI? If you haven’t, you should try it out… just finish reading the rest of this post before you give it a go so you’ll know how to handle what will come. The problem is this: if a modal VI’s front panel is open when you run an application that uses that VI then the modal VI takes focus from the Main VI’s front panel. If that modal VI has been set to not allow the user to close the VI (often a good idea) then you cannot close the modal VI or interact with your main VI’s front panel. Awesome huh? It is also interesting to note that when a modal window has stolen focus, you will hear a windows beep sound (assuming you have speakers) when you try to click on any other front panel. Below are listed some methods for dealing with this problem and also ways of avoiding the problem altogether.
The “Three-Finger-Salute” 
For this method you first press Control-Alt-Delete to bring up the Task Manager for windows and then kill the LabVIEW task which exits your running VI and everything else (Note: Control-Alt-Esc brings up the task manager directly). This is the most brute force method but is likely the most common method. This method’s main issue is that if you have any unsaved changes to your VIs there is a possibility you could lose them.
In Windows 7 (and possibly Vista, Windows 8 and 10 as well) when you hover over an application icon in the task bar, you get a pop up list of all open windows associated with that application. Mousing over each window gives you the option to close it, even if you are unable to give it focus because of the modal window. This will work unless you have disabled the panel close option of that main VI. If that is the case you can instead close the project explorer window as that will stop execution of all child VIs.
If you’re not in Windows 7 you could create a VI that runs when opened and than systematically aborts all VIs in memory. That is the idea of EasyVIAborterAuto. Note there is also a non-automatic version, EasyVIAborter, that shows a dialog that lets you abort VIs selectively. While this is a nicer interface than the “Auto” version, for it to work with some already running modal windows you need to set the tool’s window to be modal as well. There are many other posted VI online that do about the same thing; I am only showing one possible option. Click HERE to see more information and to download the VI.
Another idea would be to systematically close any open modal windows that are not currently running when you first run your application. MGI has a newly released function that can be dropped on the block diagram of your main VI that will do precisely that. This function has been added to the MGI library as of version 22.214.171.124 of the application control package . Like all other MGI library packages, this package can be installed using VI Package Manager.
- Allow the user to close the window. If you enable this option you need to make sure to properly handle a panel close event. Otherwise, you can hang the application in a different way.
- You can set the VIs you want to change to modal in the build specification. This method requires a bit more work in setting up the build specification and also does not allow you to properly test out all your various window interactions in the LabVIEW development environment.
- You can programmatically set the windows to modal when they run.
- Never use modal windows! Doesn’t help with that old code you have to support.