multiselect listbox

This is a discussion on multiselect listbox within the Windows Programming forums, part of the Platform Specific Boards category; Hi all; How do you get all the files selected in a list box? i have created a list box ...

  1. #1
    Registered User The15th's Avatar
    Join Date
    Aug 2001
    Posts
    125

    multiselect listbox

    Hi all;

    How do you get all the files selected in a list box? i have created a list box like so;
    ClientFilesLST = CreateWindowEx(WS_EX_TOPMOST|WS_EX_STATICEDGE,"Lis tBox","",LBS_MULTIPLESEL | LBS_NOTIFY | WS_BORDER | WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hWnd,(HMENU)IDL_CLFLS,g_hInst,0);

    and i tried this to get the selected files

    a = SendMessage (ClientFilesLST, LB_GETSEL, 0, 0);
    SendMessage (ClientFilesLST, LB_GETTEXT, a, (LPARAM) ClientFileName);
    but it seems to only get the last selected file, so i thought i might need an array to hold all the files in, but by brain doesn't seem to be working and im in a big hurry here. Thanks Heaps everyone.
    cya
    arrh, i got nothing good to say.
    http://www.praxis1.vic.edu.au/home/dcola/

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Use:

    int which_files[10]; //For a maximum of 10 selections
    .
    .
    a = SendMessage (ClientFilesLST, LB_GETSELCOUNT, 0, 0);
    SendMessage (ClientFilesLST, LB_GETSELITEMS, a, (LPARAM) which_files);

    This gives you the items selected.

    ClientFileName[which_files[0]]
    ClientFileName[which_files[1]]
    etc.

  3. #3
    Registered User The15th's Avatar
    Join Date
    Aug 2001
    Posts
    125
    Thanks heaps swoopy!
    arrh, i got nothing good to say.
    http://www.praxis1.vic.edu.au/home/dcola/

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, 01:46 PM
  2. cant load dialog with listbox, help
    By terracota in forum Windows Programming
    Replies: 2
    Last Post: 11-22-2004, 06:11 PM
  3. 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, 08:52 PM
  4. Listbox stealing focus
    By Calthun in forum Windows Programming
    Replies: 3
    Last Post: 09-12-2004, 04:36 PM
  5. Getting FULL filename from listbox
    By Garfield in forum Windows Programming
    Replies: 8
    Last Post: 01-27-2002, 07:28 AM

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