LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to programatically offset the position of numerous instances of a re-entrant window

Solved!
Go to solution

Hello,

 

I have a custom re-entrant error window which I call dynamically. The problem is that all of its instances open at the exact same position, so there could be multiple instances hiding behind each other.

 

Is there a tried and tested way for achieving functionality similar to the one we see in Microsoft Windows, where each new error window will open at a slightly offset position relative to the previous one to ensure they are all visible? This is such a basic necessary function that I would find it surprising if a function does not already exist.

 

However my search has been fruitless.

0 Kudos
Message 1 of 7
(4,150 Views)

You can programmatically set the front panel bounds. So when you're launching, figure out how many versions of the VI you will be launching and set the bounds accordingly. An input to your subVI could be a cluster of bounds that the launching VI generates before launching and tells each subVI where it should go.

 

Here's the Ni article on moving the front panel.

This could be useful as well.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 7
(4,143 Views)

Thank you James,

 

Yes I do use all the window position and bounds properties quite heavily already.

 

I guess my question is mostly relating to "how can I easily keep track of the numerous open instances of a re-entrant window."

 

If I could just obtain a list of all LabVIEW windows that are open I could easily find how many instances of a specific window are open and use that information to offset the position of each new window suitably.

I tried the OpenG "List open front panels.vi" but it doesn't seem to work for UI windows whether they have been called dynamically or otherwise.

 

The other option would require implementing some sort of mechanism that keeps track of the window instances but I was really hoping that there would be something readily available which can achieve what I need without much programming.

 

 

 

 

0 Kudos
Message 3 of 7
(4,132 Views)

The OpenG doesn't work with the open FP windows? That's weird...

 

What happens when you run this code? (I'm not too sure about the "2" operator. Maybe try with and without it.)

Front Panels Bounds.png

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 4 of 7
(4,120 Views)

Hi James,

 

The App.AllVIs property, which I wasn't aware of, looked promising but it proved unsuitable in this case.

 

I wrote a test VI which calls my re-entrant error window and then executes the  App.AllVIs property. I tested two cases.

 

Case A) called one error window statically and two error windows dynamically

Case B) called two error windows dynamically

 

In each case, the App.AllVIs property executed 3 seconds after the error windows popped up and the test VI went on to run an empty dummy loop.

 

In each case the App.AllVIs property returned the name of my error window just once in its output array.

So it would appear that this property returns the name of a VI just once (if it is loaded in memory) regardless of how many instances of that VI are open during runtime, and regardless of whether those instances were called dynamically or statically.

 

I haven't used the rest of the code in your screenshot as that would have just returned the bounds of over 2500 VIs in memory, which was not necessary anyway.

 

I guess I am going to have to implement an FGV which counts how many error windows are open and registers the bounds of the last opened error window . I will then integrate that into the re-entrant error window itself.

It's a shame that useful things like "re-entrant window automatic positioning offset" do not have out-of the box functions/properties in Labview to speed up development.

 

 

0 Kudos
Message 5 of 7
(4,098 Views)
Solution
Accepted by Theo_K

Ok, here is my solution.

It is quite generic so hopefully it will help others.

Message 6 of 7
(4,084 Views)

Great job! And thanks for sharing your code.

 

My next suggestion was going to be to use a FGV controlled by the launched VI instances and there you went and did it already.

I would go ahead and mark your reply as the solution, so others can find it. Kudos!

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 7 of 7
(4,062 Views)