Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListBox problem

Status
Not open for further replies.

Baal80

Programmer
Aug 14, 2004
14
PL
Hi,

I have a following problem. When I double click on an item in a ListBox, this item is moved to another ListBox - (but this is not important here). The problem is - when I doubleclick on a ListBox when NO ITEM is selected (I click ona an empty space) an error occurs. I tried to avoid this by checking in the ListBoxDoubleClick procedure:
if (ListBox->ItemIndex!=-1) [move item] but it's strange - EVEN when an item IS selected, when I debug the program it says that ItemIndex is -1. I don;t know what causes the problem... Can somebody help?
Thanks,
Baal.
 
Hmmm, something's fishy here. Neither the list box control (CListBox) nor the list control (CListCtrl) have an ItemIndex member, hence

Code:
ListBox->ItemIndex!=-1

doesn't make sense. But since you don't seem to get a compilation error, what kind of control are you using, really?

Assuming you're using a CListBox, getting the current selection is:
Code:
  int selIndex = theListBox.GetCurSel();
  if (selIndex != LB_ERR)
  {
    // Something is selected
  }


/Per

"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top