CListBox::InsertItem() not working right

This is a discussion on CListBox::InsertItem() not working right within the C++ Programming forums, part of the General Programming Boards category; according to the MSDN i can use that function to insert a list box item into a specific spot, For ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    411

    CListBox::InsertItem() not working right

    according to the MSDN i can use that function to insert a list box item into a specific spot, For me it returns an error if I make it anything other than -1 or a greater than the lowest item already there.

    Ive tried useing the ResetContent(), InitStorage(), and SetTopIndex().

    None of it helped cause the items are not being entered in the first place, it returns the LB_ERR code, but i could find nothing to say what could cause the LB_ERR code to be returned.

    I want to have a bunch of items in the list (several hundred) but there will be some skipped numbers, one set of items start with 500 index. I cant be changeing them all the time cause of backward compatability reasons.

    I could just string all the indices togather, but that would make me go back and redo alot of old stuff, and new things could just be added to the end of the list.

    I have a few other ideas, all are more complicated than just figureing out why the items arent going in to begin with. Specs show that with an average length of 30 bytes i can store 2176 different strings, so thats not the problem.

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    No one have any ideas?

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    This not a good question or what? Or dose no one know whats wrong?

  4. #4
    Unregistered
    Guest
    Without refering to the code example I can only guess at what is happening. But here goes..

    I believe the list must be continuous i.e. all elements from 0-n will be there as you add each one. This will allow you to insert into position 0 to n. To have you list jump from 0-10,500-510 you will need to create your own list or will need to fill all the intermediate values 11-499 with empty strings. This will allow you to insert at position 320. If you do this, remember to remove one from the list or what you presume to be at 500 will have moved to 501.

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    I was hopeing to find a way so the list items wouldnt have to have consectuave indices.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function not working
    By sloopy in forum C Programming
    Replies: 31
    Last Post: 11-12-2005, 07:08 PM
  2. Program Not working Right
    By raven420smoke in forum C++ Programming
    Replies: 2
    Last Post: 09-16-2005, 03:21 AM
  3. Trying to eject D drive using code, but not working... :(
    By snowfrog in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2005, 07:47 PM
  4. x on upper right corner not working
    By caduardo21 in forum Windows Programming
    Replies: 1
    Last Post: 02-20-2005, 07:35 PM
  5. cygwin -> unix , my code not working properly ;(
    By CyC|OpS in forum C Programming
    Replies: 4
    Last Post: 05-18-2002, 04:08 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21