LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Prevent Sub-VI in SubPanel from Scrolling Beyond the Controls

Solved!
Go to solution

Calling all SubPanel experts,

 

I currently have a system in place similar to the screenshots I've attached (can't attach the actual screenshot for sensitive data reasons) where I have a Sub-VI inserted into a SubPanel.

The problem I am facing is that once the sub-vi is loaded into the SubPanel, the user is able to scroll infinitely beyond where the controls are. However, I know it is possible to (none-programatically) stop this from happening because, in the example I attached, this is the case!

 

I cannot for the life of me figure out what the example VI I attached does differently to mine. I have tried inserting the VI into the SubPanel before running it and vice versa, I have tried putting my controls in a cluster control and putting that in a sub-vi and then the SubPanel. I am lost, any help would be appreciated. Thanks in advance!

 

tl;dr I have inserted a Sub-VI into a SubPanel and it allows the user to scroll past all the controls infinitely into nothingness. How do I fix that?

Download All
0 Kudos
Message 1 of 14
(826 Views)

Why not remove the scroll bars from your VI? They do not have to be visible. I never show scroll bars for the VI, only certain indicators.

0 Kudos
Message 2 of 14
(815 Views)

Minions_0-1697569390830.png

Minions_1-1697569454541.png

The scroll bars are automatically generated based upon the vi front panel size with respect to the Sub-Panel size.  If the vi is modified to a smaller size or the sub-panel stretched larger, it is possible to fit within the Sub-Panel window without scrollbars.

 

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 3 of 14
(789 Views)

What you want to do is to "lock" the Front Panel.  There are two ways to do this (I learned the second way about a month ago by an answer on this Forum).  

  • Use OpenG.  There is a decades-old set of "useful LabVIEW Functions" called the OpenG Library that you can find on the LabVIEW Tools Network using VIPM.  One function is called "Fit VI Window to Largest Dec" (Dec = Decoration).  I go to the Front Panel, figure out what I want to appear in the sub-Panel, and draw a Decoration (I usually use a Flat Box or a Raised Frame), putting what you want to appear in the Run-Time window within (or on top of) that Decoration.  Put the function, itself, as the first thing the sub-VI runs, and when it does, it will "snap to" the size of the Decoration.  [You'll want to make the sub-Panel space the same size, of course).
  • An easier way was suggested by @RTSLVU.  When you open a new VI, look at the upper-left corner of the Front Panel -- there's a little "Origin" dot and a Top and Left edge.  Make what you want visible in the sub-Panel fit in this space (i.e. nothing to the left of the left edge or above the top edge).  Bring things you don't want to see down and to the right, so you can resize the window so it shows (a) the "origin", and (b) what you want to see in the final sub-Panel "front Panel".  Now go to Window Size and choose "Set to Current Panel Size", and go to Window Run-Time Position and check the box that says "Scroll panes to origin at run time".  Adjust the size of the sub-Panel, and when you run the VI, it will be properly sized and placed.

Bob Schor

Message 4 of 14
(784 Views)

The scroll bars are necessary as the content spans further than the edge of the screen so you need to be able to scroll to view it all. However it lets you scroll past the end of the content, which is the problem. Hope this clarifies some things.

0 Kudos
Message 5 of 14
(713 Views)

Hello, I attempted both of these solutions, to no avail. I have attached screenshots of an obfuscated version of my FP and BD, the VI Properties, as well as Run-Time demonstrations in the hopes that this sheds some light on what I'm doing wrong.

 

I have also attached the example code I was using to debug (which works the way I want mine to) as a reference. It is the "Scrollable Cluster.zip" attachment.

 

Any help on this matter is greatly appreciated, it has been driving me insane.


Thanks in advance

0 Kudos
Message 6 of 14
(707 Views)

Hello, the scroll bars on the SubPanel do not appear to be automatically generated for me. They just allow me to scroll infinitely. Also, as I have mentioned in a previous post, the scroll bars are necessary for this implementation as the controls span further than the edge of the application window.

 

I am using LabVIEW 2021 if that is of any use.


Thanks in advance

0 Kudos
Message 7 of 14
(705 Views)

The only way I know of to get scrollbars (of arrays, panels, etc.) to do what you want is to use your own scrollbar controls, and program their behavior.

 

So you make a vertical and horizontal scrollbar, place them at the right and bottom of your FP (that is sized to your subpanel's size). That catch the scrollbar's value change events, and move the FP origin accordingly, correcting the scrollbar's positions.

 

Or make yet another subpanel, so you have a VI that manages the scrollbars and the panel inside it's subpanel and control that panel's origin...

 

Using the size of the FP you want to move and it's view size, limit the scrollbar's values and set it's page size...

 

Doable, but quite daunting. You might want to pick your battles (and skip this one).

 

 

Message 8 of 14
(696 Views)

Thank you for the suggestion, I may try that if all else fails. However, I know that is is possible to do without any extra programming. The example project I attached as a zip file manages this without any extra (as does this other example I found that I have attached).

 

I'm confused why theirs work and mine doesn't. I even found a Sub-VI within my own project that, when inserted into the SubPanel, had the properties I wanted (not scrolling infinitely and adjusting the scroll bar according to the borders of the outermost controls in the sub-vi). So, I figured I'd copy that VI and see if I can replicate its properties with the controls I actually want. However, somehow even when copying a Sub-VI I knew worked, when I add the controls I want, it no longer works the way I intended?

 

I feel like I am missing a small setting somewhere, perhaps even an issue with the SubPanel itself rather than the Sub-VI I am inserting into it?

 

Sorry for all the hassle, and thank you for your help and time thus far.

0 Kudos
Message 9 of 14
(686 Views)
Solution
Accepted by topic author Caxaho

Hello all!

 

I have found the solution!

 

The Sub-VI that is inserted into the SubPanel must be running constantly (even if the Run VI invoke node method has been called, which is a requirement anyway). What I mean by this is that the Sub-VI must be being called by something, either by the Sub-VI itself (i.e. a while loop within the Sub-VI forcing it to run constantly), or by calling the VI by reference within the main window BD. This may have been obvious to some folks, but I figured scrolling shouldn't be affected by whether or not the Sub-VI is actively executing considering I had already ran the "Run VI" invoke method (maybe needs documenting/naming better so people understand its purpose more?)

 

Anyway, I hope this helps anyone else stuck on this issue!

 

 

Message 10 of 14
(676 Views)