LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a EVENT_PANEL_MAXIMIZE attribute in CVI's panel callback?

I want to response the panel maximize & minimize event, but I can't find the EVENT_PANEL_MAXIMIZE or EVENT_PANEL_MINIMIZE, how can i do?
Thanks.
0 Kudos
Message 1 of 7
(4,935 Views)

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;
}



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 2 of 7
(4,925 Views)
Mr. Bozzolo, thanks for your reply.
 
I try your method and it's work now, but I still have a problem, it can not response panel minimize action.
Would you please try and solve this problem?
 
Thanks again.
 
drcool
06.11.20
0 Kudos
Message 3 of 7
(4,900 Views)
Well, minimize event is a little bit more complicated than maximize and on some cvi versions seems not so consistent... anyway, take a look at this thread and that other that is mentioned in the first one, Which version of CVI are you using? I have tested these hints on version 7.1 and some condition was not able to catch (e.g. maximize directly from the minimized app: in this condition the EVENT_LOST_FOCUS is not firing until the moment I click on the panel... Smiley Surprised ...)


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?
0 Kudos
Message 4 of 7
(4,890 Views)

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.

0 Kudos
Message 5 of 7
(4,871 Views)

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



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?
0 Kudos
Message 6 of 7
(4,864 Views)

... since CVI 2012 there are EVENT_PANEL_MINIMIZE, EVENT_PANEL_MAXIMIZE, and EVENT_PANEL_RESTORE events available Smiley Happy

0 Kudos
Message 7 of 7
(3,977 Views)