The problem related to your program is that when you use the spacebar for checkmarking an item and the EVENT_MARK_STATE_CHANGE event is processed the listbox isn't updated. The update is done when the EVENT_COMMIT event is passed into your callback. The following change in your program will help:
int CVICALLBACK cb_Listbox (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int checked;
int len;
char *sEntry;
int idx;
switch (event)
{
case EVENT_COMMIT:
GetCtrlIndex (panel, control, &idx);
GetLabelLengthFromIndex (panel, PANEL_LISTBOX, idx, &len);
sEntry = malloc(len+32); // Alloc a little bit more data
GetLabelFromIndex (panel, PANEL_LISTBOX, idx, sEntry); // get label
IsListItemC
hecked (panel, PANEL_LISTBOX, idx, &checked);
if (checked == 1)
sprintf(sEntry, "Entry %i is checked", idx);
else
sprintf(sEntry, "Entry %i is not checked", idx);
ReplaceListItem (panel, PANEL_LISTBOX, idx, sEntry, idx);
free(sEntry);
break;
}
return 0;
}
Regards,
Heinrich Illig
National Instruments