05-09-2016 01:31 PM
I have a dialog that I want to make floating, so it stays on top of other windows, while allowing interaction with other windows. However, my dialog can also receive some keyboard shortcuts, and I can't seem to make the window both floating and active. I have to click on the window before it becomes active and can accept keyboard shortcuts, which kindof defeats the purpose of the shortcuts.
I've tried using the FP Open/activate property, but it seems to have no effect on actually "activating" the window. Does anyone know the trick?
Solved! Go to Solution.
05-09-2016 02:39 PM
I also tried setting the Is Frontmost property of the window, and this did not solve the problem.
05-09-2016 03:44 PM
What do you mean by "while allowing interaction with other windows"? Normally, one Window has the focus and receives the keystrokes -- in the case of a Dialog Window, it stays on top of other Windows and insists on the Focus until dismissed. If that is the behavior you want, make this a sub-VI and set its Window property to Dialog.
05-09-2016 05:09 PM
Yes, Bob, a dialog is usually Modal, and you have described what modal means: window has focus and doesn't allow change of focus. However, this is not what I'm after. I'm using the other of the three window-behaviour options: Floating. This means the window is always on top, but does not retain sole focus, so you can interact with other LabVIEW windows. The question is how to prgramatically cause the floating window to have focus so it can recieve keystrokes.
05-09-2016 06:14 PM
You need to step back and rethink what you're asking.
The purpose of floating is so that it's always on top but doesn't retain focus.
You want it always on top while retaining focus.
Do you see the disconnect?
From what little you've told us, it sounds like the entire purpose of this floating window is to accept key strokes. Why not add that functionality to your main VI and skip this whole process of popping open a window?
05-09-2016 06:53 PM
I think what I'm asking is perfectly clear, correct, and logical. There is no disconnect. If you actually have tried htis you'd know that a floating window can *relinquish* focus, but it can also HAVE focus. It opens by default without focus, ut attains focus when clicked on. Focus on, focus off. The trouble is, and here's my question: how does one programatically put focus on a floating window?
As I mentioned, I can give it focus by clicking on the window. I hve not found a way to give it focus programatically. This is what I want to do. The functionality I described is exactly what I want. And this is really the only question here. The answer may very well be this is not possible, in which case I would consider this a flaw, if not a bug, in LabVIEW.
05-09-2016 07:51 PM
What you asked for was confusing, poorly communicated, and the furthest thing from clear. But, now that you've seen several different people all miss your intent, we appreciate you taking the time to ACTUALLY explain what you're looking for.
You're looking to do something that you're going to best be served by using .NET constructors to change the focus. http://stackoverflow.com/questions/2315561/correct-way-in-net-to-switch-the-focus-to-another-applica... has an example of using .NET for this exact purpose.
Call it a bug, or flaw, all you'd like.
05-09-2016 08:25 PM
05-09-2016 09:37 PM - edited 05-09-2016 09:38 PM
You would be best served biting your tongue when asking people for help. Here are several options (I don't have LabVIEW at home, so cannot confirm these work properly at this time):
Using a LabVIEW property: http://zone.ni.com/reference/en-XX/help/371361M-01/lvprop/vi_fp_windowis_frntmst/
Using the WinAPI. It takes two steps. You have to get the window handle: https://msdn.microsoft.com/en-us/library/windows/desktop/ms633515(v=vs.85).aspx and then you can set the active window: https://msdn.microsoft.com/en-us/library/windows/desktop/ms646311(v=vs.85).aspx. This method I know works, because I have LabVIEW code written for these API calls.
The reason your method doesn't work is that the Activate input only applies when the window is opened for the first time.
Now that you have your answers, I will also say that what you are doing is poor design. You will have to constantly sit there and reactivate the window., since your user may be clicking away to another window at any time.
05-10-2016 06:21 PM
HI Matthew, Thank you for your help. As I mentioned, the frontmost property does not work in this case, for floating windows. Hence the problem I'm facing.
Interestingly, the activate input does not work for a floating window when using the FP.Open method, even if set on the first call. (LV2014) This is why i have been calling this a bug, but I don't know if I understand the intention of the floating window. Although you can activate it by clicking on it, perhaps it was conceived as a window that would not usually be activated, so it can't be done programatically.
I was going to attempt the Win API next, and that's hopeful