06-26-2012 11:40 AM
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?
Solved! Go to Solution.
06-26-2012 12:13 PM
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
06-26-2012 12:41 PM
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
06-27-2012 05:39 AM
@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?
06-27-2012 06:07 AM - edited 06-27-2012 06:11 AM
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.
06-27-2012 08:18 AM
Set the pop up VI as Modal in it's properties.
/Y
06-27-2012 11:34 AM
Thanks for everyone who replied.
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.
06-27-2012 02:09 PM
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
06-28-2012 05:54 PM
Like this?
06-30-2012 09:42 AM
@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 😛