I have a main vi and a subvi which is opened from the main vi. Main vi is maximized (takes all screen) and subvi is small one. My desired behavior is: the main vi opens the subvi, main vi must be visible in the background, but it must not collect any event (e.g.. If button on the main vi is clicked when the sub vi is opened).
I know that can be achieved with setting the subvi to modal, however I do not want to do that (because subvi opens also some other windows, ...).
Is there any other way to prevent the main vi to collect events while the subvi is opened (e.g. To disable whole front panel at once)?
I wonder why you are afraid of using modal sub-vi.
Your sub-vi can open another sub-vi which would have modal property without any problem.
If you really hate using modal property, I can suggest one method.
When your subvi starts running, set a global boolean variable - let's call it evFlag. Clear evFlag when you close that sub-vi.
And make your event handler of main vi not respond on the specified event, i.e. in every cases of the event, open a case structure which is switched by evFlag. Place your handler inside the FALSE case.
Anyway, I think he methode above is a very foolish solution.
I can use modal property, because then some other features in the subvi won't work (I have several subvis in the subvi).
Your method could work (but I think it's not a good approach) if you have one or two such windows, but I have 50 of them and I have to do that in each of them 😞
As an alternative to a modal dialog, you can use the VI Server "version" of the modal functionality, by using the FP.IsFrontmost VI property.
Alternatively, you can programmatically "take" focus from your subVI once, when it launces by using the Application / Bring To Front invoke method.
You can also programmatically give the Focus to the subVI from the main VI, that is a bit more compicated as you need a VI reference to your SubVI (See Calling a VI by Reference). Then you can for example use FP.IsFrontmost again.
with you solutions the window will be always on top, but I can still click in "bottom" window and an event will be generated there.