Example Code

Move Controls and Indicators during Runtime Using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This VI allows the user to move controls and indicators on the front panel while the VI is running

 

Description

This VI uses events to monitor the mouse movements and property nodes to move the front panel objects to follow. The main Example.vi has a waveform chart, Boolean indicator, and a stop control. The block diagram uses two property nodes to create a reference for the front panel objects. It then uses three SubVI’s.

The “Drag & Drop New Multi.vi” VI takes in the references and registers events for the mouse moves. The for loop will accommodate multiple references. The reference is then sent to “Drag & Drop Run Multi.vi” where an event structure with the dynamic event registration feature responds to the mouse movements. A while loop in the main VI repeats this SubVI until the Stop button on the front panel is pressed. Then the “Drag & Drop End Multi.vi” unregisters the events. To implement these VIs, create a reference to the object and make it an input to the Example.vi within the Zip folder. To use it with multiple objects, build an array of references.

 

Requirements

LabVIEW Full Development System 2012 or compatible

 

Steps to Implement or Execute Code

To Execute: 

  1. Run the VI
  2. Click and hold objects to move the front panel objects
  3. To stop the VI, press the “STOP” button

 To implement in your code:

  1. Unzip the Move Controls and Indicators during Runtime LV2012 NI Verified.zip folder and add the VIs to your project
  2. Copy the following code from Move Controls and Indicators during Runtime.vi into your main VI

To implement as a SubVI:

  1. To use Move Controls and Indicators during Runtime.vi as a SubVI, go to the front panel of Move Controls and Indicators during Runtime.vi
  2. Add a VI Refnum to the front panel by going to the Controls Palette » Modern » Refnum
  3. Right-click on the Connector Pane in the top right corner of the front panel
  4. Select Add Terminal
  5. Click on one of the terminals in the Connector Pane, then click on the Stop button
  6. Click on the other terminal and click the VI Refnum
  7. In the block diagram, connect the VI Refnum control to the reference node of the VI Property node
  8. Drag the VI icon next to the connector pane into the block diagram of your VI
  9. Create a VI Server Reference in your VI and wire it to the Move Controls and Indicators during Runtime.vi SubVI. You can also wire a stop control

 

Additional Information or References

VI Block DiagramMove Controls and Indicators during Runtime BD.jpg

 **This document has been updated to meet the current required format for the NI Code Exchange. **

Al B.
Staff Software Engineer - TestStand
CTA/CLD

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
S.Stock
Member
Member
on

Nice! 😊

Is it possible to add some sort of  "snap to grid" function to this? 🤔
(Or alternatively so that the objects (controls/indicators/etc) cannot be placed on top of each other?)

________________________________________________
"Science is about knowing, while engineering is about doing"
skmnhtwins
Member
Member
on

Do you know if it is possible to move a control/indicator into a presently selected page in a tab control?  I tried placing a tab control on the example but it didn't seem to work