LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

problem with InsertListBoxItem

Hallo everybody,

I wrote the CALLBACK given below.
My problem:
The Item do not appear in the list. What's wrong?




int CVICALLBACK GENERATE_FUNCTION (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    char name[MAX_PATHNAME_LEN];
    int count;  

    GetNumListItems (mainPanel, PANEL_LISTBOX, &count);      // gets the last Number Of Items

    switch (event)
        {
        case EVENT_COMMIT:
            GetCtrlVal(panel, Panel2_STRING, name);         // gets the value of a STRING
            InsertListItem (mainPanel, PANEL_LISTBOX, -1, name, (count+1));
            DiscardPanel(panel);
        break;
        }
    return 0;
}
0 Kudos
Message 1 of 4
(3,021 Views)

Apparently your code sounds good, so here some general hints to try to discover what's happening.

1. Does InsertListItem return an error code? Try getting the return code of the function and look at its value:

err = InsertListItem (...)  err is =0 if the function is succesful.

2. Is mainPanel variable visible inside the callback? Is it loaded with the correct handle of the panel on which the listbox is?

3. I saw the string has MAX_PATHNAME_LEN size: is it filled with a pathname? If so, maybe the software is trying to interpret a backslash as an escape code, which is not, and so gives erroneous result in inserting the text in the listibox. Try putting the usual "Hello world!" in the string control and see if it's displayed correctly.



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 2 of 4
(3,009 Views)
Hallo Roberto,

I've found my error by a coincidenc:

the "mainpanel" was in reality not a mainpanel, it was a tab panel.

By writing to the tabpanel I made the error:
I didn't wrote to the variable, used by the TABPANEL declaration with "EasyTab_ConvertFromCanvas" but to variable I used vor "LoadPanel".
So the changes I made could not disaplayed and no error appeared, because the function itselves was correct.

But another question came to my mind:
Why does this all not work, when I use the same variable for "EasyTab_ConvertFromCanvas" and "LoadPanel" ?

Florian
0 Kudos
Message 3 of 4
(2,992 Views)

Greber,

The reason it didn't work was because the handle that you get back from 'EasyTab_ConvertFromCanvas' is not a handle to an easytab panel.  Rather it's a handle to a container for easytab panels.  The way you get an easytab panel handle is from 'EasyTab_LoadPanels'

0 Kudos
Message 4 of 4
(2,988 Views)