LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a simple way to programatically tell which VI window has focus?

I was hoping that someone might know a simple way to tell which VI window in an execution tree has focus in a Windows environment? I have a routine which uses the LVWutil32.llb routines to help manage the opening, closing, minimization and restoration of windows (along with the window's appearance & properties) but if the user decides to manually restore a minimized window (perhaps to look at some front-panel data) and forgets that the window is not the one currently with focus, it can lead to confusion as none of the controls work. I'd like to include in my window management routine the ability to set or clear a "Got Focus?" indicator on each of the windows it controls (or, as an extreme, I could disable & gray-out all controls on an out-of-focus window).

Determination of which window within an execution tree that actually has the focus is getting quite complicated, especially if I allow for the possibility of more than one execution tree. I'm hoping that there might be some simple property or method to do this that I have overlooked...
0 Kudos
Message 1 of 9
(3,399 Views)
can you use the application property "All VI's in memory" to get a list of the vi's , then by using the vi front panel property "IS Frontmost" determine which is front most ???
0 Kudos
Message 2 of 9
(3,393 Views)
No, "Is Frontmost" does not seem to mean the same as "has (current) focus".
0 Kudos
Message 3 of 9
(3,385 Views)
Perhaps I should try a bit harder to explain what I mean by "focus".

Imagine that you start a top-level VI running that has a subVI which, when invoked by the topVI, will display its front panel and later, when closed, will hide its front panel.

We all know that if the topVI is running and we manually open the front panel of the subVI (by clicking on its disk file) none of the front panel controls on the subVI will work even though it shows that it is running. This is because the topVI has the execution focus and the subVI is waiting to be invoked.

In this state the "Is Frontmost" property will report that the subVI window is indeed frontmost (if it is open and frontmost).

I've attached an example (LV v7.0) to demonstrate this.

Message Edited by Warren Massey on 04-12-2005 09:04 AM

0 Kudos
Message 4 of 9
(3,358 Views)
Hello,

When subVI is "Waiting to Run" the controls on the front panel don't have any effect (since the VI is not running yet). However, in this situation the property Execution->State will still show Running so this is not what you are looking for either.

Basically, there is no property node that indicates the 'execution focus' and you would need to keep track of which VI is running yourself, like you are doing in the example.

Good luck and best regards,
Shakhina P.
NI
0 Kudos
Message 5 of 9
(3,338 Views)
Shakhina,

First of all, thanks for the answer!

May I respectfully request that this be added to a wishlist somewhere? While the example I submitted did do a rather primitive sort of tracking, it was by its very nature rather simplistic and would not scale very well to a larger project.

Warren
0 Kudos
Message 6 of 9
(3,337 Views)
OpenG has a "Find VI with Focus" VI installed in the Application Control palette. I'm not sure if this will get you what you want (it uses IsFrontmost), but it at least allows you to discard some windows, and besides, having OpenG VIs is a good idea in general - some of them are extremely useful.

Message Edited by tst on 04-13-2005 10:46 AM


___________________
Try to take over the world!
0 Kudos
Message 7 of 9
(3,327 Views)


@tst wrote:
OpenG has a "Find VI with Focus" VI installed in the Application Control palette. I'm not sure if this will get you what you want (it uses IsFrontmost), but it at least allows you to discard some windows, and besides, having OpenG VIs is a good idea in general - some of them are extremely useful.

Message Edited by tst on 04-13-2005 10:46 AM





Yes, I agree that the OpenG VIs are a very good idea. In fact the OpenG "Find VI with Focus" VI is buried within the example I posted earlier in this thread and is used there to show that the IsFrontmost property is not a good indication of which VI has execution focus.
0 Kudos
Message 8 of 9
(3,308 Views)
Hi Warren,

Thanks for your feedback, I have filed this suggestion to our R&D. You can submit product suggestions online as well: go to www.ni.com, click on Contact NI and then feedback (under Product Feedback).

Thanks and have a great day!
Shakhina P.
NI
0 Kudos
Message 9 of 9
(3,305 Views)