Showing results for 
Search instead for 
Did you mean: 

Is there a way to determine if a vi is running in a subpanel?

I have a vi based on a dialog box and now want to run this vi in a subpanel. If the vi is running in a subpanel I want to hide the OK button
is there a way to determine if your vi is executing in a subpanel?

0 Kudos
Message 1 of 23
Yes, it is possible: you have to open a reference to the subVI, connect that reference to a property node and read the Execution.State property of the VI. The necessary code is shown in the image attachment. The nodes to open and close a VI reference and the property node are located in the Application Control subpalette of the function palette.
0 Kudos
Message 2 of 23
AlejandroZ ,

When I perform this action within the vi running in a subpanel or at top level the execution state always reports
that the vi is "Run at top level".

Any other ideas?

0 Kudos
Message 3 of 23

This correct behavior. Since you're dynamically calling the VI whose display is in the subpanel Mode, the state of this VI will either be:
-"RUN at Top Level" since it is a VI that is the top-level VI in an active hierarchy
-"idle" if it's not running.

Cyril Bouton
Active LabVIEW Developper
Message 4 of 23
You could add an indicator to the VI in the subpanel indicating whether it is being run in a subpanel and set it to true when you call in in a subpanel. You can then use its value to set the visibility of the OK button. Let me know if this example works for you.
Robert Mortensen
Software Engineer
National Instruments
Message 5 of 23
I have a similar question but a little bit more spicer... 😃
Assuming that I have the main VI with a subpanel and the subVI that is running in the subpanel is just like any other application "waiting" to press the exit button(event loop structure,etc..). If I set the exit button to toggle using the reference of that panel in the main VI the application doesn't stop. I am able to see that the button change its state but the event structure doesn't catch that event and never quits in the normal mode like when I use the subVI in stand alone.

What do I need to do?

In the main VI, I have an event structure that is caching the exit from a exit button... then I exit the while loop and execute a flat structure. in the flat structure, I am setting the exit button from the subVI, to do so, I kept alive the subpanel reference so in that way I am able to set the exit control to false and then to true with an delay inbetween, but the subView's event structure doesn't detect that change....

Help please.

Alex Rodriguez
0 Kudos
Message 6 of 23

In my opinion the decision whether to show ok button because your loaded in a subpanel need to be moved to the caller of the VI. So you would have an input in the VI that say Run mode:

1. Run mode as regular top level, you show ok and cancel button and do normal event monitoring on the ok or cancel button. You can event set this as default value, so if you want to run it as regular VI, say in debugging you can just run the VI.

2. Run mode as subpanel, then the caller should pass a user defined event that is fired when the main VI window exit button is pressed. Also when VI is run as subpanel, you should hide the ok and cancel button. So your terminate signal can either come from the ok and cancel button or the user defined event, in either case there will be only one active scenario at all time.


0 Kudos
Message 7 of 23
Don't worry! I found I way to do it.

I am using the Value(Signaling) property of the ext button. In that way I am exit the subpanel application and the I exit my main VI.


Alex Rodriguez.
Alex Rodriguez
0 Kudos
Message 8 of 23

This answer might come a bit too late but there will probably be others which will need the solution.


You read the VI property Front Panel Window:State and then the property Front Panel Window:Native Window. If the state is Standard, Minimised or Maximised (which means that the front panel is open somewhere) and the native window handle is 0 (there is no win32 window) then the VI is in a subpanel. It's only in this situation that the VI doesn't have a window (in the Windows win32 sense).

Message 9 of 23

please could you post an example vi with this property node, it would be useful, thank you!

0 Kudos
Message 10 of 23