LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stealing focus

Solved!
Go to solution

Hello.

I need to create a pop-up action in my VI, and make it show up above all other applications - steal focus.

 

In the searches i saw that C++ and CVI there are functions for that sort of problems. However i was searching invoke and property nodes of both application and VI, and didnt found anything that worked.

 

Windows were shifting within the application, but never pop up above other applications, including modal windows.

 

How can i steal focus to my application?

________________________________________________________________________
"When I need the side of a building to view all the code..." -Mark Yedinak
"...when you need a navigation window to view the navigation window..." -Jeff Bohrer
0 Kudos
Message 1 of 16
(4,202 Views)

Can you define what you mean by "above"? Do you mean on top of all other windows or at the top of the screen?

 

If on top of all windows, then setting your VI to "modal" will do that.

 

If you want something similar programmatically, you can use the property node "Is Frontmost" (Select Class VI Server->VI->VI, then property Front Panel Window->Is Frontmost).

 

Rob

0 Kudos
Message 2 of 16
(4,196 Views)

Rob's reply should work if you are talking about LV windows. If you are trying to float over all windows then I BELIEVE you will have to invoke the OS to do that.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 16
(4,189 Views)

@Robert Cole wrote:

Can you define what you mean by "above"?


By above i mean in front of any other application.

 

"Is frontmost" property node is bringing the window in front of other windows in the same EXE aplication, but not in front of other program's windows.

Same goes for "Modal" window type. Modal window does not steal the focus if i'm in another application, say any windows explorer window.

That's how i tested it - with windows explorer focused, above my VI.

 

Maybe there's any unconventional way? Like C# or .NET wrapped with LV? Or User32.dll?

________________________________________________________________________
"When I need the side of a building to view all the code..." -Mark Yedinak
"...when you need a navigation window to view the navigation window..." -Jeff Bohrer
0 Kudos
Message 4 of 16
(4,171 Views)

Modality is the thing you are looking for.

 

The problem by your request is, that it is commonly acknowledge to NOT use this feature anymore as you want it to have.

See here for some detailed information about modality.

 

You are looking for system modal dialogs. As stated above, using such dialogs is not state of the art since pre-emptive OS'es are the norm. The reason is that system modal dialogs are in conflict with pre-emption, hence they should not be used.

 

In LV, you will not have system modality as selectable option because of above discussed reason. You can, nevertheless, use the Windows SDK to set windows system modal. Please search in the MSDN or with google for those infos.

 

 

hope this helps,

Norbert

 

EDIT: The option to set a front panel "modal" (VI Settings) refers to application modal dialogs. So swapping to other applications (window will be put into the back) but when returning to the LV application, the modal dialog will come to front by itself. This is true if you have only one dialog open which is modal. If you have several modal dialogs open, the last front most dialog should reappear as front most, but it is possible that another modal dialog comes to front instead.

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 5 of 16
(4,165 Views)

Set the pop up VI as Modal in it's properties.

/Y 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 16
(4,147 Views)
Thanks for everyone who replied. Smiley Happy

Norbert_B wrote:

You are looking for system modal dialogs. 


Yeah well no.

I am not trying to lock user's attention to one specific window above all other applications, i need just to bring it to front.

In a sense of "Hey, look, your nuclear powerplant is going fubar, stop watching youtube!". Just make it show up, dont lock attention.

 

Modal window was popping up above all LV windows, not above windows explorer or any other non-LV window. Smiley Sad

________________________________________________________________________
"When I need the side of a building to view all the code..." -Mark Yedinak
"...when you need a navigation window to view the navigation window..." -Jeff Bohrer
0 Kudos
Message 7 of 16
(4,124 Views)

If you are using Windows, use the Windows API Function Utilities (32-bit) for LabVIEW


http://sine.ni.com/devzone/cda/epd/p/id/4935

 

Message 8 of 16
(4,116 Views)
Solution
Accepted by topic author UFOslava

Like this?

Message 9 of 16
(4,087 Views)

@paul_a_cardinale wrote:

Like this?


Sweet! Exactly like this...

 

User32.dll never failed me yet. And, if I'm not mistaken, it is a part of Windows API.

Thank you for the replies, guys 😛

 

________________________________________________________________________
"When I need the side of a building to view all the code..." -Mark Yedinak
"...when you need a navigation window to view the navigation window..." -Jeff Bohrer
0 Kudos
Message 10 of 16
(4,061 Views)