11-15-2006 07:40 PM
11-16-2006 02:44 AM
You can get this event while trapping a EVENT_PANEL_SIZE event in panel callback. Here an example of a panel callback that detects if it has been maximized. The callback also obtains and displays panel and screen dimensions in pixels:
int CVICALLBACK thePanelCallback (int panel, int event, void *callbackData,
int eventData1, int eventData2)
{
int ph, pw, sh, sw, wz;
char msg[512];
switch (event) {
case EVENT_PANEL_SIZE:
GetPanelAttribute (panel, ATTR_WINDOW_ZOOM, &wz);
if (wz == VAL_MAXIMIZE)
MessagePopup ("Sizing", "Panel has been maximized.");
GetPanelAttribute (panel, ATTR_WIDTH, &pw);
GetPanelAttribute (panel, ATTR_HEIGHT, &ph);
GetScreenSize (&sh, &sw);
sprintf (msg, "Panel size is %d x %d pixels.\n", pw, ph);
sprintf (msg, "%sScreen size is %d x %d pixels.", msg, sw, sh);
MessagePopup ("Sizing", msg);
break;
}
return 0;
}
11-19-2006 09:52 PM
11-20-2006 03:06 AM
11-20-2006 09:55 PM
It's my own code:
int CVICALLBACK callbackMainPanel (int panel, int event, void *callbackData,
int eventData1, int eventData2)
{
int panelZoom;
switch (event)
{
case EVENT_GOT_FOCUS:
GetPanelAttribute (mainpanelhandle, ATTR_WINDOW_ZOOM, &panelZoom);
if (panelZoom == VAL_NO_ZOOM)
{
// MessagePopup included for demonstration purposes.
MessagePopup ("Restored", "Restored");
}
break;
case EVENT_LOST_FOCUS:
GetPanelAttribute (mainpanelhandle, ATTR_WINDOW_ZOOM, &panelZoom);
if (panelZoom == VAL_MINIMIZE)
{
// MessagePopup included for demonstration purposes.
MessagePopup ("Minimized", "Minimized");
}
break;
case EVENT_CLOSE:
QuitUserInterface (0);
break;
}
return 0;
}
I cannot enter the EVENT_LOST_FOCUS, because every time the callback function responsed the EVENT_GET_FOCUS at first. Why and how can i do?
by the way, I use the CVI 8.0.
11-21-2006 02:18 AM
According to my observations, there is no real need to trap EVENT_GOT_FOCUS event. Here my code for the panel callback:
static int wz = VAL_NO_ZOOM;
switch (event) {
case EVENT_LOST_FOCUS:
GetPanelAttribute (panel, ATTR_WINDOW_ZOOM, &wz);
if (wz != oldwz) {
sprintf (msg, "Event: %s\n", UILEventString (event));
if (wz == VAL_MAXIMIZE)
strcat (msg, "Panel has been maximized.");
else if (wz == VAL_MINIMIZE)
strcat (msg, "Panel has been minimized.");
else
strcat (msg, "Panel has been restored to original dimensions.");
MessagePopup ("Sizing", msg);
oldwz = wz;
}
break;
case EVENT_PANEL_SIZE:
GetPanelAttribute (panel, ATTR_WINDOW_ZOOM, &wz);
if (wz != oldwz) {
sprintf (msg, "Event: %s\n", UILEventString (event));
if (wz == VAL_MAXIMIZE)
strcat (msg, "Panel has been maximized.");
else if (wz == VAL_MINIMIZE)
strcat (msg, "Panel has been minimized.");
else
strcat (msg, "Panel has been restored to original dimensions.");
MessagePopup ("Sizing", msg);
oldwz = wz;
}
break;
default:
if (event != EVENT_GOT_FOCUS) {
sprintf (msg, "Event: %s\n", UILEventString (event));
MessagePopup ("Panel", msg);
}
break;
}
With this code I trap almost all resizing the operator can perform, but with those strange conditions:
1. When restoring or maximizing a minimized panel, I receive no panel event at all. If I click on the panel after it has been restored, I receive the LOST_FOCUS event together with the LEFT_CLICK one
2. In all conditions other than minimizing the panel, I receive both LOST_FOCUS and PANEL_SIZE events: this means that some attention would need to be payed to not executing the relevant code twice
08-11-2012 02:52 PM
... since CVI 2012 there are EVENT_PANEL_MINIMIZE, EVENT_PANEL_MAXIMIZE, and EVENT_PANEL_RESTORE events available