Menu

#32 TListWindow::GetSelIndexes returns 1 too many

unspecified
closed
5
2012-09-27
2008-04-16
Ruben P
No

(owlnext 6.20.7)
When using TListWindow::GetSelIndexes, it fills indexes with maxCount+1 indexes if there are more than maxCount items selected. That is not correct.

proposed change:

int
TListWindow::GetSelIndexes(int* indexes, int maxCount) const
{
int count = 0; // number of selected items found

if (GetStyle() & LVS_SINGLESEL)
return -1;

// get index of first selected item
//
int index = CONST_CAST(TListWindow*, this)->SendMessage(LVM_GETNEXTITEM,
TParam1(-1), MkParam2(LVNI_ALL|LVNI_SELECTED, 0));

// while index indicates a selected item
//
/ original algorithm fills one more than maxCount
while (index != -1) {
indexes[count] = index;
count++;
if (count > maxCount)
break;
/

// proposal for fix
while (index!=-1 && count<maxCount ) {
indexes[count] = index;
count++;

// get next selected item
//
index = CONST_CAST(TListWindow*, this)->SendMessage(LVM_GETNEXTITEM,
        TParam1(index), MkParam2(LVNI_ALL|LVNI_SELECTED, 0));

}

return count;
}

Discussion

  • Ognyan Chernokozhev

    Logged In: YES
    user_id=873706
    Originator: NO

    Fixed, will be included in next patch

     
  • Sebastian Ledesma

    It was fixed on 2008-May-26.
    The current version of OWLNext (6.20.10) has the fix.

     

Log in to post a comment.