LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Using one callback function for all the controls in the program

Hello, i have to make a program which uses one CallBack Function for all the controls in the program(numeric,string,gauge) etc

 

The callback function is supposed to take the values from the controls and format them into one string which is sent to another function which splits the string using the scan function into the values again and does stuff to them like adds them into functions or other controls.

 

I also need to identify the particular control who s events i declared and i not the others, also i want all my values to be kept.

 

This is my GUI:HomeWork3.PNG

 

int CVICALLBACK cCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int iSesKeyID,n;
double iNumVal;
char iTxtBoxVal[255];
char iStrVal[255];
double iSlideVal,iGaugeVal;
char buff[255];
switch (event)
{
case EVENT_COMMIT:
switch (control)
{
case INPUT_RING:
GetCtrlVal(input,INPUT_RING,&iSesKeyID);
break;
case INPUT_NUMERIC:
GetCtrlVal(input,INPUT_NUMERIC,&iNumVal);
break;
case INPUT_STRING :
GetCtrlVal(input,INPUT_STRING,iStrVal);
break;
case INPUT_NUMERICGAUGE:
GetCtrlVal(input,INPUT_NUMERICGAUGE,&iGaugeVal);
break;
case INPUT_NUMERICSLIDE:
GetCtrlVal(input,INPUT_NUMERICSLIDE,&iSlideVal);
break;
case INPUT_TEXTBOX:
GetCtrlVal(input,INPUT_TEXTBOX,iTxtBoxVal);
break;
}


n = Fmt(buff,"%s<ses: %d Numeric: %f String: %s TextBox: %s Slider: %f Gauge: %f", iSesKeyID, iNumVal, iStrVal, iTxtBoxVal, iSlideVal,iGaugeVal);

SetCtrlVal(input,INPUT_STRING_2,buff);

break;
}
return 0;
}

 

This is what i made, also can i pass these values as parameters?The ouput controls are in the tabs 1 and 2 from the second panel, how am i supposed to pass the values witohut losing them?

 

 

0 Kudos
Message 1 of 2
(4,362 Views)

It's not clear to me what do you mean by "losing the values".

 

If those panels are all handled from the same application, you could simply put an appropriate SetCtrlVal immediately after each GetCtrlVal to mirror the control values into the corresponding controls on the second panel. Of course you need to retain the handle of the second panel in a variable which can be used by the first panel callback.

 

Different is the case if you are intending to exchange values between different applications: in such case some more details on your scenario sould be useful.



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 2
(4,357 Views)