LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Bring a panel to front / maintain focus in CVI

Hi,
 
I have an application in CVI 7.1 that uses the following to obtain the panel handle and name: -
 
 /* Get current Panel Handle */
 handle = GetActivePanel();
 /* Get current Panel Name */
 GetPanelAttribute(handle,ATTR_CONSTANT_NAME,panelname);
 
The problem that I am having is that every now and then a pop up from another program (Email etc.) pops up and releases the focus from the main panel. This causes my application to crash stating that the panel in focus does not have the correct information.
 
Other than making sure that no other program is running when my application is running (something I cannot guarentee) or changing the above code to hard code the panelname (this routine is in a generic dll) is there a way of forcing a panel back into focus.
 
Within my application I have a Timer function that I could use to perform this function or I could create a seperate thread that is always checking the focus of the panel.
 
Is this possible or am I looking from something that doesn't exist?
 
Any suggestions welcome.
 
0 Kudos
Message 1 of 3
(4,849 Views)

You could always look for the EVENT_LOST_FOCUS event in the panel's callback to identify this situation. What you do with the information depends on your program, but the function SetActivePanel() might appear in the solution somewhere.

JR

Message 2 of 3
(4,843 Views)
And in case you do want to bring your application on top of other applications running, you can use MakeApplicationActive () function, that brings your topmost panel to the front.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 3 of 3
(4,839 Views)