LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Champions advices needed

Hi fellows !

 

I have a question for all the LabVIEW aficionados here.

 

Today, I answered to a question on the French part of the forum. This question was how to set focus back to a VI front panel (foreground)  that was used to call and execute another VI (and show its front panel of course).

 

I just made an example like this :

 

The main VI

VI.png

 

The sub VI :

sousVI.png

 

As you can see, in order for the sub VI to set focus back to the main VI before it terminates its execution, I use a VI reference control to get the reference of the main VI. But I was wondering if this method is really efficient and correct ? What would you have done in this case to get the reference of the main VI ?

 

Thanks in advance for your help and advices.

 

Regards,

 

 

Da Helmut
Voir le profil de Maxime M. sur LinkedIn - View Maxime M.'s profile on LinkedIn
Download All
0 Kudos
Message 1 of 10
(3,994 Views)

Two ideas:

 

  • The subVI could place itself in the background instead.
  • The subVI could autonomously reference the calling VI via the call chain primitive.

 

Message 2 of 10
(3,981 Views)

Two ideas:

 

  • The subVI could place itself in the background instead.
  • The subVI could autonomously reference the calling VI via the call chain primitive.

 

 


 

Hi Altenbach,

 

Thanks for the quick answer.

 

Actually the sub VI has to close its front panel so placing it to the background can't be possible. But when doing that does it sets focus back to the main VI ?

 

I tried the call chain primitive but I only get the sub VI, I think this is normal because I am "dynamically" calling the sub VI. What do you think about that ?

 

subVI.png

 

subVI2.png

 

Thanks again !

 

Regards,

Da Helmut
Voir le profil de Maxime M. sur LinkedIn - View Maxime M.'s profile on LinkedIn
0 Kudos
Message 3 of 10
(3,972 Views)

Main has already a ref to the dynamically called vi. You can register for the FP.Close Event of that vi in the Main, and when it fires, set the FP to focus and unregister the event.

The advantage is to have the focus methods all in the same VI (so the responsible is inside the main).

 

Felix

Message 4 of 10
(3,962 Views)

Main has already a ref to the dynamically called vi. You can register for the FP.Close Event of that vi in the Main, and when it fires, set the FP to focus and unregister the event.

The advantage is to have the focus methods all in the same VI (so the responsible is inside the main).

 


 

Hi Felix,

 

Thanks for the answer.

 

It seems like it is a good idea, but I cannot manage to make it work because when I registre for the FP.Closed  event, I get an error saying that the FP of the sub VI is not open.

 

I could register for the event after the FP is open but my event structure won't accept it. How would you do that ?

 

Regards,

Da Helmut
Voir le profil de Maxime M. sur LinkedIn - View Maxime M.'s profile on LinkedIn
0 Kudos
Message 5 of 10
(3,954 Views)

This way I don't get any error, but the main VI won't get focus back...

 

yeah.png

extrait.png

extrait2yeah.png 

Da Helmut
Voir le profil de Maxime M. sur LinkedIn - View Maxime M.'s profile on LinkedIn
Download All
0 Kudos
Message 6 of 10
(3,946 Views)

I don't have LV available, so I can't test. But I'd place it between the FP.Open and The RunVI method. You can wire the dynamic refnum (out) of the Event structure from the inside.

 

Felix

Message 7 of 10
(3,942 Views)

Well, it doesn't work too...The sub VI is opened but it doesn't run maybe because the FP.Close event registering is outputting an error.

 

extr.png

 

When I place it after the Run VI method, the sub VI runs well, but I get an error when I close it.

 

Well, I hope we'll end up finding out how to do it this way. In the meantime I wish you a nice weekend.

 

Regards,

Da Helmut
Voir le profil de Maxime M. sur LinkedIn - View Maxime M.'s profile on LinkedIn
0 Kudos
Message 8 of 10
(3,932 Views)

I'm not sure (as I can't test right now), but propably this isn't working due to the fact mentioned here

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Add-an-event-that-would-fire-when-a-spawned-subVI-exit...

The "Panel Close" event can be used with callback however it will only trigger when the subVI exits via the Window Close button (X in the upper right corner).

 

The way suggested there is to use a callback queue to the main to signal the exit of the dynamically spawned subVI.

 

In your scenario, why not just use the simple call by reference node with a Window.State=hidden before and a Window.state=standard after?

 

Felix

Message 9 of 10
(3,924 Views)

 

I'm not sure (as I can't test right now), but propably this isn't working due to the fact mentioned here

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Add-​an-event-that-would-fire-when-a-spawned-subVI-exi...

The "Panel Close" event can be used with callback however it will only trigger when the subVI exits via the Window Close button (X in the upper right corner).

 

The way suggested there is to use a callback queue to the main to signal the exit of the dynamically spawned subVI.

 


 

I did the test with the Window Close button and the event was not fired. Maybe I am doing something wrong.

 

I think that using a queue is the best option in this case. I'll try it. I didn't think about this solution thanks for bringing it up.

 

 


 

In your scenario, why not just use the simple call by reference node with a Window.State=hidden before and a Window.state=standard after?

 


 

Because with this way, if I have several VIs opened, I am not sure that the calling VI will be the first window on the foreground (I think, I didn't test that).

 

Thanks again for your help and patience.

 

Regards,

Da Helmut
Voir le profil de Maxime M. sur LinkedIn - View Maxime M.'s profile on LinkedIn
Message 10 of 10
(3,918 Views)