LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Application Lost Focus Event.

Hi NI,

My application is set to be SetPanelAttribute(panelHandle, ATTR_WINDOW_ZOOM, VAL_MAXIMIZE) and I need to capture the event generated when the computer operator changes to a different application running on the background, e.g. ALT+TAB to activate an application. I tried to use EVENT_LOST_FOCUS but it does not get generated in the case above.

Thanks,

Julio Jansson.
0 Kudos
Message 1 of 6
(3,993 Views)
EVENT_LOST_FOCUS is generated for the active panel when you switch to another application. It doesn't matter how you switch (Alt-tab, Start menu, Task bar, etc). If you want to act on EVENT_LOST_FOCUS, you need a panel callback. See the attached sample. It just counts the number of times the panel loses focus.
0 Kudos
Message 2 of 6
(3,991 Views)
Hi Again,

Sorry! I should've mentioned that also my main application requires all other panels that it holds to be child panels of the main application panel, hence every time I select a particular panel of my application I also get an EVENT_LOST_FOCUS in the main application panel, so my problem really is to identify if the new focus is one of my child application panels or an external application running in the machine. I have modified and attached an example of what I mean.

Thanks,

Julio Jansson.
0 Kudos
Message 3 of 6
(3,989 Views)
One idea would be to create one panel callback for all the child panels which swallows the EVENT_LOST_FOCUS (i.e. return 1) so it doesn't reach the parent callback.

On the other hand you could use the "panel" variable of the callback which is identifying the panel which received the "event" and act as required.

I hope I could help.
-----------------------
/* Nothing past this point should fail if the code is working as intended */
Message 4 of 6
(3,977 Views)
Have every panel (main and child panels) call the same callback (PanelCallback in my example).
On EVENT_LOST_FOCUS, call GetActivePanel. If it returns 0, no panel is active: another app is active. See the new and revised sample.
0 Kudos
Message 5 of 6
(3,973 Views)
P.S.
When you post files, you don't need to include the .cdb (debug database) file. It just inflates the size of your post and it will get recreated when we rebuild anyway.
Include the following files in your post.
*.prj
*.c
*.h
*.uir
0 Kudos
Message 6 of 6
(3,972 Views)