Resizing LabVIEW Front Panel Programmatically

Updated Oct 19, 2023

Reported In

Software

  • LabVIEW

Issue Details

I want to be able to programmatically resize and position the front panel of either my current VI or a SubVI. How can I implement this functionality?

Solution

Resizing a VI programmatically can be accomplished using property nodes, as shown in the VI snippet below:
 
  1. Add an Open VI Reference to the block diagram by right-clicking the block diagram and selecting Funtions»Programming»Application Control»Open VI Reference.
  2. Add a Current VI's Path VI found in Funtions»Programming»File I/O»Constants»Current VI's Path and connect it to the path input of the Open VI Reference VI.
  3. Right-click on the VI Reference terminal and select Create»Property Node for VI Class»Front Panel Window»Panel Bounds.
  4. Right-click the FB.PanelBounds text and select Change to Write.
  5. Right-click the FB.PanelBounds terminal and select Create»Constant.
  6. Add a Close Reference to the block diagram by right-clicking the block diagram and selecting Funtions»Programming»Application Control»Close Reference.
  7. Wire the VI as shown above.

Additional Information

Open VI Reference converts the file location to a VI reference that the Property Node can read.  Any VI can be referenced (though the property change will not have an effect unless the selected VI is open), including the referencing VI itself.  The property used to resize the front panel is FP.PanelBounds, which accepts a cluster of four integers controlling the left, top, right, and bottom bounds of the front panel (in pixels from the top left of the primary monitor). 

If you plan to create an executable program based on this VI, you will need to replace the Open VI Reference with the VI Server Reference.  This function simply references the application it is located in.  This is necessary for executables since there is no VI to reference.

There are a number of other VI attributes that can be changed using property nodes, and more information on each can be found in the LabVIEW help.  Note that the property node is dynamic; the available properties will change depending on what type of reference is wired to it.