10-10-2018 11:32 AM
I am wanting the sub-vi that I have that is called by my main VI to be brought in front of all windows (even widows that are not a part of the LabView program, a web browser for example). I attempted placing the Bring Front Panel to Foreground.vi attached in in this post and running it first thing when my sub VI was called, but it just remained stuck on the Bring Front Panel to Foreground.vi and would not progress beyond it. The development computer is Windows 10 running LabView 2016, the deployment computer is running windows 7 and does not have LabView installed (I am building the main VI and running it as an .exe on the deployment computer). I have altered the Bring Front Panel to Foreground.vi only to change the "elapsed time" from 5 seconds to 0.5 seconds. Am I implementing the Bring Front Panel to Foreground.vi incorrectly ? I assumed that I would just run Bring Front Panel to Foreground.vi first thing from my own sub VI to bring that sub vi to the foreground, but there is not anything specific in the post about use other than it doesn't work on Windows 10, which the deployment computer is not. The vi from the post with my 0.5 second modification to it is attached to this post.
10-10-2018 12:32 PM - edited 10-10-2018 12:35 PM
Inside the Bring Front Panel In Foreground VI, there is a loop with a stop button wired to its conditional terminal. This means that the VI won't stop until you press the stop button on its front panel, which since you are calling it as a subVI, you probably won't do.
I don't really know how this VI is meant to be used, but maybe you are supposed to take it apart and put the code in the subVI loop into your own main loop? Or if you don't need it to keep your VI continuously in the foreground and just do so at the beginning, then maybe just take the loop out of the subVI?
Either way, try to avoid using sequence structures in your code. It looks cleaner without them.
10-10-2018 12:43 PM
For starters, your subVI loop will continue to execute until the stop button is pressed. That is why you never move forward in your code. You can simply use the property node to bring the front panel to the front.
You can also get rid of the frame structure in your code. Use dataflow to control the execution order of your code. IN the case of the property nodes, use the error in/error out terminals. Frame structures should be used sparingly and only when you need to force dataflow where none exists. You should also look at using state machines in your code to control your execution sequencing.
10-10-2018 12:46 PM
Does FP.IsFrontmost actually do what OP is asking though? They said they want it to be in front of all windows, not just LabVIEW windows.
10-10-2018 12:46 PM - edited 10-10-2018 12:48 PM
@prettypwnie wrote:
Inside the Bring Front Panel In Foreground VI, there is a loop with a stop button wired to its conditional terminal. This means that the VI won't stop until you press the stop button on its front panel, which since you are calling it as a subVI, you probably won't do.
I don't really know how this VI is meant to be used, but maybe you are supposed to take it apart and put the code in the subVI loop into your own main loop? Or if you don't need it to keep your VI continuously in the foreground and just do so at the beginning, then maybe just take the loop out of the subVI?
Either way, try to avoid using sequence structures in your code. It looks cleaner without them.
From the looks of the picture, the case structure is actually influencing dataflow. Without it, that invoke node can execute at any time, possibly at the wrong time. (If this was intentional, there are much better ways of enforcing dataflow.)
To the OP - learn dataflow basics. It's not as confusing as it sounds if you ruthlessly apply this one sentence to all your code: "Remember that a node executes only when data is available at all of its input terminals and supplies data to the output terminals only when the node finishes execution."
Edit: Oops, I'm late to the party, but at least I brought a dish.
10-10-2018 12:50 PM - edited 10-10-2018 12:52 PM
@prettypwnie wrote:
Does FP.IsFrontmost actually do what OP is asking though? They said they want it to be in front of all windows, not just LabVIEW windows.
I am not sure but it is worth a try. Of course the original problem of the program not advancing past the call to the subVI had nothing to do with using the property node or not. It just seems this might be a more straightforward solution over making calls to external DLLs.
10-10-2018 12:50 PM
Well, obviously I'm not suggesting to just take out the sequence structure and do nothing else for data flow.
But OP, if you just wire up the error wire to that property node that will enforce data flow just fine.
Also, if you take out the sequence structure and keep Bring Front Panel In Foreground just sitting there running in parallel on the diagram, will probably actually work. I DON'T recommend it because you should have an actual mechanism to stop that VI, but... if you are running in exe and use Quit LabVIEW at the end, it would probably work fine.
10-10-2018 01:01 PM
@prettypwnie wrote:
Well, obviously I'm not suggesting to just take out the sequence structure and do nothing else for data flow.
But OP, if you just wire up the error wire to that property node that will enforce data flow just fine.
Also, if you take out the sequence structure and keep Bring Front Panel In Foreground just sitting there running in parallel on the diagram, will probably actually work. I DON'T recommend it because you should have an actual mechanism to stop that VI, but... if you are running in exe and use Quit LabVIEW at the end, it would probably work fine.
Sorry, I wasn't trying to beat on you; I just wanted to make sure that the OP, who is inexperienced with LabVIEW, judging from the picture, understood what you and I already do. 🙂
10-10-2018 02:53 PM
To all, I inherited this code and had not gotten to refactoring it yet, as it was functional how it was, but since I can tell it is like nails on a chalkboard to you all :), it has been corrected with the error wire controlling data flow instead of flat sequence structures. I am not incredibly experienced with LabView, but I do understand dataflow basics. Nonetheless, I appreciate the instruction on flat sequence structures and data flow.
I should have paid more attention to the inherited Bring Front Panel to Foreground.vi to notice that the while loop needed user input to terminate, my mistake there. Removing that while loop did not correct the issue. I was under the impression that FP.IsFrontmost only acted on LabView program windows, not all windows, which is why that was not the first thing I turned to. I attempted it and the FP.IsFrontmost property node did not work either. The updated Bring Front Panel to Foreground.vi is attached.
10-10-2018 03:12 PM
I think if you remove the while loop, then it will bring your VI to the front, but it won't stay there, eg: if you click on another window, it will now go behind it, because you are not running that VI to keep it in front.
I would recommend keeping the while loop inside that VI. Then run the VI in parallel - eg: don't wire up the error wires to anything. Then make some way you can signal to the subVI when your main code has stopped so the subVI stops. Like pass a queue and send a stop message on the queue at the end. Does that make sense or do you need more explanation?