08-24-2017 01:09 AM
That's basically it. I have a main VI and in it is a Sub Panel window that shows another VI through it. But when it comes up, the Front Panel of the shown VI is off center and I have to readjust it with the scroll bars that appear on the sides of the Sub Panel.
I looked this up and someone said that the Sub Panel Invoke Node has a property which can direct it to center on the shown VI, but I have yet to find it. Is there another way?
Solved! Go to Solution.
08-24-2017 01:24 AM
hi
You can use the Window Run-time Position property of the shown vi(vi need to be inserted into the sub panel) from the VI properties.
regards
Senthil
08-24-2017 01:32 AM
Okay, I'll give it a try.
08-24-2017 07:47 AM
Here's what I do --
When my Main VI calls the sub-VI, the sub-VI executes "Fit VI Window to Largest Decoration, which "snaps" the Front Panel to the borders of the Decoration (I usually use Raised Frame), so what appears in the sub-Panel is the Frame and whatever I've placed inside it. It fits size-wise (because I made the Decoration the right size) and fits in the Window as I designed when I made the sub-VI's Front Panel.
Another "trick" you can use to keep your controls/indicators/decorations "aligned" on your sub-VI is to band-select them then choose to "Group" them (you know the little alignment controls at the top of the Front Panel and Block Diagram windows? The third one has the "Group" command). Now they all will "move as a unit".
Bob Schor
08-28-2017 10:28 AM
Thanks for the suggestion, but when I implemented the Fit to Window function in the Sub VI and then ran the Main VI, it gave me this error: Error 1148 This Property is read only while the VI is in a Sub panel.
I think I ran across this error before and have never figured out how to fix it. But the Fit to Window Function returns no error when I run the Sub VI by itself. Maybe there's a clue to the fix in that?
08-28-2017 10:31 AM
I looked it up and Error 1148 means - This property is read only while the VI is in a subpanel.
Is there any way to get around this?
08-28-2017 10:39 AM
What property? Be more specific. Post code.
08-28-2017 10:46 AM
Well, that's just it. The Error itself is very vague. As far as I know I'm not using any property nodes or anything.
As for the code, my program is pretty basic. I created a Main Vi with a Sub Panel window to show a Sub VI. Then within the Sub VI I applied a function called Fit VI Window to Decoration, which basically shrinks the the Sub VI's Front Panel to to the size of the largest "decoration" that you have on the Front Panel. So if you draw a big rectangle around everything then the Front Panel will shrink to fit the parameters of the rectangle.
Anyway, it seems the problem has something to do with that Fit VI to Decoration function. If I take it out I don't get the error anymore. And oddly if I run the Sub VI by itself, not through the Main VI, then the function gives no error whether it's active in the Sub Vi or not.
08-28-2017 10:53 AM
This message was actually broken off from another thread that provided more information. Since the important information is in the first thread, I'll merge the two threads together.
08-28-2017 11:05 AM
So the technique is to start the sub-VI before you put it in the sub-Panel.
I've used two different methods to do this. In one, the code that ran in the sub-Panel was coded as an Action Engine, with an Init Action that had the Fit to Largest Decoration in the code. I called the Action Engine with Init, then wired its reference to the Insert VI sub-Panel function. In the other, the code was written as a Message Handler, "spawned" using Start Asynchronous Clone (to get it running), either set to self-initialize or called from the Host with an Initialize Message, and then wired (via its reference) to the Insert VI function.
Bob Schor