LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

List Box error:out of range

Hi everyone:
   Thank you for your attention.
I am using List Box Control to display test information, but occur error, the hint is out of index range.
I list part relative code for you, maybe you can find some clues and help me .
//====================================================
#define TEST_STATUS_MAX_SIZE ((long) 102400)  
 
long GUI_TestStatus_Write (char *svalue_in)
{
 long lreturn = GUI_ERR_NONE;
 int ilist_item_count = 0;
 
 if (iMainPanelHandle > 0)
 {
      lreturn = (long) GetNumListItems (iMainPanelHandle, MAINPANEL_LISTBOX_TESTSTATUS, &ilist_item_count);
      if ( ilist_item_count > TEST_STATUS_MAX_SIZE )
      { //max data allowed exceeded. clear window.
               lreturn = (long) ClearListCtrl (iMainPanelHandle, MAINPANEL_LISTBOX_TESTSTATUS);  
      }
  
       lreturn = (long) InsertListItem (iMainPanelHandle, MAINPANEL_LISTBOX_TESTSTATUS, -1, svalue_in, 0);
     if (AUTOSCROLL_ENABLE == iAutoScroll)
     {  
               if (ilist_item_count >= 1)
               {
                 lreturn = (long) SetCtrlIndex (iMainPanelHandle, MAINPANEL_LISTBOX_TESTSTATUS, (ilist_item_count-1));
               }
       }
 }
 return lreturn;
}
 
//====================================================
the system break down in SetCtrlIndex (), i do not know how to resolve it
Thank you in advance!
0 Kudos
Message 1 of 2
(3,132 Views)
Are you getting this error consistently or some times only? I'm asking you because when you clear yor listbox because of max data limit exceeded, you should reset  ilist_item_count variable to zero, and you aren't: in this case, when you set listbox position with SetCtrlindex you are pointing to an element that no longer exists.


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 2
(3,127 Views)