ListBox & LB_SETCARETINDEX / LB_SETSEL

This is a discussion on ListBox & LB_SETCARETINDEX / LB_SETSEL within the Windows Programming forums, part of the Platform Specific Boards category; Hi there, I'm having a little trouble changing the selection item inside a list box. Here is the code im ...

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    28

    ListBox & LB_SETCARETINDEX / LB_SETSEL

    Hi there,

    I'm having a little trouble changing the selection item inside a list box.

    Here is the code im currently using:

    Code:
    void PreviousFile()
    {
    	int iCurSel = SendMessage(GetDlgItem(hWnd, IDC_LIST), LB_GETCURSEL, (LPARAM)0, (WPARAM)0);
    	int iTotal = GetListBoxInfo(GetDlgItem(hWnd, IDC_LIST));
    
    	if (iCurSel = 0)
    	{
    		SendMessage(GetDlgItem(hWnd, IDC_LIST), LB_SETSEL, (LPARAM)1, (WPARAM)iTotal);
    	}
    	else
    	{
    		SendMessage(GetDlgItem(hWnd, IDC_LIST), LB_SETSEL, (LPARAM)1, (WPARAM)(iCurSel - 1));
    	}
    	PlayFile();
    }
    I've also tried numerous different 'LB' types to no avail.

    Im using an extended ListBox style. (NOT MFC!)

    Any Ideas?

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    28
    I have tried that, if you read the page it says..

    Code:
    Remarks
    
    Use this message only with single-selection list boxes. You cannot use it to set or remove a selection in a multiple-selection list box.
    Like i said in my first post, i'm using 'extended', which lets you select more than one at a time.

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  5. #5
    Registered User
    Join Date
    Nov 2003
    Posts
    28
    aaah.. i didn't see that one, works a treat!
    Thanks for the fast help mate!


    Marc

  6. #6
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Glad it worked - makes up for me reading but not absorbing the meaning of "Im using an extended ListBox style."
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ListBox Extra Data Storage
    By Welder in forum Windows Programming
    Replies: 1
    Last Post: 11-01-2007, 02:46 PM
  2. Listbox search
    By Elsindes in forum Windows Programming
    Replies: 4
    Last Post: 04-09-2007, 04:47 PM
  3. cant load dialog with listbox, help
    By terracota in forum Windows Programming
    Replies: 2
    Last Post: 11-22-2004, 07:11 PM
  4. How to cast a ListBox item to an int for a switch statment?
    By Swaine777 in forum C++ Programming
    Replies: 8
    Last Post: 09-26-2004, 09:52 PM
  5. Getting FULL filename from listbox
    By Garfield in forum Windows Programming
    Replies: 8
    Last Post: 01-27-2002, 08:28 AM

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