LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a panel the active window once another window has been selected

How can I make my panel the active window once I click outside the panel?  I am only using one panel in may application and if i click on the desktop then the panel is not active and I don't get any updates to the panel shown.  It only comes back when I display a pop-up panel.  Basically I want the panel to always be active and if someone clicks outside the panel I want to bring it back to the front.  I'm using 8.0 on XP.
0 Kudos
Message 1 of 10
(5,612 Views)
Have you tried SetActivePanel() ?


Message 2 of 10
(5,607 Views)
I tried both SetActivePanel and DisplayPanel.  If I'm running in debug mode then the window comes back to the front but when I just run the executable then it doesn't.
0 Kudos
Message 3 of 10
(5,603 Views)
Maybe ATTR_WINDOW_ZOOM too.

But, you're fighting the Windows desktop paradigm to some extent I think.  This isn't so much a CVI issue as it's a windows issue - even a CVI main panel has to follow the Windows rules Smiley Wink

I sometimes maximize the window, hide the system menu, make the window non movable, non-resizable, to force the user into leaving the panel alone as much as possible.  A determined used can still get "underneath" your window and get to other applications if they want to badly enough.

If you ran a timer on your panel that, when fired, forced the main panel to be active / visible, maybe that would work.

Menchar
Message 4 of 10
(5,602 Views)

Thanks Menchar.  I think you're right on fighting the Windows issues.  I did find some stuff in the help to help out with this also.  I always try to design test systems to be run by someone with a 3rd grade education but I guess even a 3rd grader can click outside a window.  I know this because our VP keeps telling me that the sometimes window goes away and doesn't update.

One thought, when I display a pop-up window then the panel comes back to the front.  Maybe I could disply and delete a pop-up window real quick to bring it back?  I guess hoping for a simple Bring-to-Front is a bit much for Windows though.

 

Steve

0 Kudos
Message 5 of 10
(5,601 Views)
You're welcome.

You might try a short timer on your main panel (200 msec or so) with a quick callback that sets the main panel active.  On return from the callback, ProcessSystemEvents gets called, which should redraw the window.  This imposes a burden on the system to be redrawing the main panel constantly though.

If you could set the main panel "modal", that would protect the main panel from mouse clicks onto the other panels in your app, but not from panels in other processes.

I think you can do an InstallPopup() call on any panel handle and make it modal.

The panel attribute VAL_FLOAT_ALWAYS looks interesting.

I think I've used it on splash panels at app startup - this will work I think -heck, if nothing else, turn your "main" panel into a modal popup with VAL_FLOAT_ALWAYS - keep the "real" main panel hidden maybe.

Bob


Message 6 of 10
(5,596 Views)
Steve,

SetPanelAttribute (handle, ATTR_FLOATING, VAL_FLOAT_ALWAYS);

Will be able to give you a panel that is always on top. If you also want it to always be in focus, you can make that panel active on the EVENT_LOST_FOCUS so that it will only lose focus for a short time.

Brandon Vasquez | Software Engineer | Integration Services | National Instruments
0 Kudos
Message 7 of 10
(5,554 Views)

Brandon,

That seems to work when i'm running in the debugger but if i just launch the executable I still have problems.  If I click anywhere while it is running I stop getting screen updates.  Most of the updates use SetCtrlVal to update the text in the panel.  I believe part of the problem is the main body of the code is run in a callback and the DisplayPanel is run in the main loop.

0 Kudos
Message 8 of 10
(5,547 Views)
If your main body of code is in a callback, if you are in a callback, no other callbacks will execute until you call ProcessSystemEvents. Once you call ProcessSystemEvents, it postpones the current callback for the new callback being executed. Because of this, it is very easy to get stuck in one callback and no updates will then show up. Be sure you debug this and are calling ProcessSystemEvents regularly if you are in a callback for an extended amount of time.

Brandon Vasquez | Software Engineer | Integration Services | National Instruments
0 Kudos
Message 9 of 10
(5,528 Views)
That was the thing I was looking for.  Thanks Brandon, it works now.
0 Kudos
Message 10 of 10
(5,521 Views)