04-14-2014 08:40 PM
Template code(from help document):
GetNumCtrlArrayItems(ctrlArray, &count);
for (i=0; i<count; i++)
SetCtrlVal(panelHandle, GetCtrlArrayItem(ctrlArray, i), i%2);
My user interface info:
I define 2 control arrays ,here are my panel and arrays
My call back code of OK button:
int CVICALLBACK Ok (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int i,temp_control,count;
switch (event)
{
case EVENT_COMMIT:
GetNumCtrlArrayItems(CTRLARRAY_2, &count);
for (i=0; i<count; i++)
{
temp_control = GetCtrlArrayItem(CTRLARRAY_2, i);
ResetTextBox(panelHandle, temp_control, "test");
}
break;
}
return 0;
}
This is the problem:
I want to change the text in the text box, according to the define of control array ,we should call
GetNumCtrlArrayItems(CTRLARRAY, &count);and GetCtrlArrayItem(CTRLARRAY, i);
but, when I click ok button, funtion GetNumCtrlArrayItems return -4.
And, I use CTRLARRAY_2 instead of CTRLARRAY, when I click ok button, the result is like this
Who can explain this for me ? Is this a bug of Labwindows/CVI 2013?Thank you very much .
Solved! Go to Solution.
04-15-2014 12:15 AM - edited 04-15-2014 12:16 AM
As you can read in the help, you do not use the control constant name in this function; instead, you should call GetCtrlArrayFromResourceID to obtain the handle to use in subsequent functions on this component.
The error you are receiving correctly states Invalid handle.
04-15-2014 12:21 AM
Haha, It's great!
Thank you very much .