LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Capture the event of minimizing panel in cvi 6

Hello,
How to capture the minimizing panel event ? Hope when click the top right minimized button ,I can receive the message .

David
0 Kudos
Message 1 of 5
(3,281 Views)
When a panel is minimized, CVI receives an EVENT_LOST_FOCUS. When you receive that event, check the panel attributes to see if the panel is minimized.
1. Create a callback function for the panel:
1.1 In the UI Editor, double-click on a blank spot on the panel to edit the panel (or select the panel and goto Edit >> Panel).
1.2 Enter a function name in the box labeled Callback Function, then click OK.
1.3 In the UI Editor, select the panel, then goto Code >> Generate >> Panel Callback
2. Edit the panel callback to check if the panel is minimized.
2.1 If in the UI editor, select the panel and goto Code >> View >> Panel Callback.
2.2 In the EVENT_LOST_FOCUS case, add the following code.
case EVENT_LOST_FOCUS:
GetPanelAttribute (panelHandle, ATTR_WINDOW_ZOOM, &panelZo
om);
if (panelZoom == VAL_MINIMIZE)
{
// add your code here.
// MessagePopup included for demonstration purposes.
MessagePopup ("Minimized", "Minimized");
}
break;
Message 2 of 5
(3,281 Views)
At the top of your panel callback (before the switch statement), add the following declaration.
int panelZoom;
0 Kudos
Message 3 of 5
(3,281 Views)
AIS,

I have tried the work you mentioned , but if click the windows desktop ,it can also result in the "lost focus event" , how to avoid it ?

David
0 Kudos
Message 4 of 5
(3,281 Views)
As I stated in my earlier answer, if you want to capture the event of a panel being minimized, you need to trap EVENT_LOST_FOCUS and then check if the panel attribute said the panel is minimized. You need to do both, not just trap EVENT_LOST_FOCUS.
If your panel is active and not minimized and you click on the desktop, you will get EVENT_LOST_FOCUS, but when you check the panel zoom attribute, it won't be minimized. EVENT_LOST_FOCUS will be generated whether or not you check for it. You can't avoid it, but you don't need to. There are multiple reasons why EVENT_LOST_FOCUS is generated. That's why (as I stated in my answer) in the case for EVENT_LOST_FOCUS, you need to check if the panel was minimized, then, only if panelZoom == VAL_MINIMIZED
, do whatever you want to do. Look at the code in my earlier answer.
0 Kudos
Message 5 of 5
(3,281 Views)