LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

A strange control array error

Solved!
Go to solution

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

panel.jpgarray.jpg

 

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

result.jpg

 

Who can explain this for me ?  Is this a bug of Labwindows/CVI 2013?Thank you very much .

 

0 Kudos
Message 1 of 3
(4,299 Views)
Solution
Accepted by topic author EastClaus

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.



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 3
(4,289 Views)

Haha, It's great!

 

Thank you very much .

0 Kudos
Message 3 of 3
(4,280 Views)