Listboxes

This is a discussion on Listboxes within the C++ Programming forums, part of the General Programming Boards category; hi how can i get the selected string in a listbox? this is what i got sofar : case WM_COMMAND: ...

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    36

    Listboxes

    hi how can i get the selected string in a listbox?

    this is what i got sofar :

    case WM_COMMAND:
    switch (HIWORD(wParam))
    {
    case LBN_SELCHANGE:
    index=SendMessage(List_Child,LB_GETCURSEL,0,0);
    SendMessage(List_Child,LB_GETTEXT,(WPARAM)index,(L PARAM)List_Selected);
    MessageBox(NULL,List_Selected,"Selected:",MB_OK);
    selected=true;
    break;
    }

    but the messagebox does not display anything...thnx

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Well, the code snippet you have here is going about it the right way, so without further details, it is not possible to say what is wrong.

    Is the LBN_SELCHANGE coming in? Remember, that message is sent when the selection in the list box is about to change.

    Is the LB_CURSEL returning a valid index, or LB_ERR?

    Are the parameters correct?

    Could be almost anything.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Registered User
    Join Date
    Jun 2002
    Posts
    36

    example please

    Can u give me an example of when u click on an item in a listbox it gets the string and stores it somewhere

    thnx adrianxw

  4. #4
    Registered User
    Join Date
    Jun 2002
    Posts
    36

    i'vew got it

    this is what i forgot

    tlength=SendMessage(List_Child,LB_GETTEXTLEN,index ,0);

    hihihi
    Time for TOTAL WAR

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Storing more data in ListBoxes in C
    By Welder in forum Windows Programming
    Replies: 1
    Last Post: 10-30-2007, 12:55 AM
  2. Replies: 2
    Last Post: 12-22-2006, 10:50 PM
  3. retrieving data from listboxes
    By luddeb in forum Windows Programming
    Replies: 6
    Last Post: 01-10-2006, 03:08 AM
  4. ListBoxes with MFC
    By omeydhomey in forum C++ Programming
    Replies: 1
    Last Post: 03-25-2003, 02:09 PM
  5. Creating/Adding to listboxes
    By punky in forum Windows Programming
    Replies: 4
    Last Post: 03-02-2003, 06:09 PM

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