Thread: Getting the index of a list box to show in a msgbox

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    4

    Getting the index of a list box to show in a msgbox

    PHP Code:
                    case IDC_LISTBOX_TEXT:
                    {
                        switch(
    HIWORD(wParam))
                        {
                            case 
    LBN_SELCHANGE:
                            {
    int index = (int)SendMessage(windowLB_GETCURSEL00);
    //I would convert index to a string here right..
    MessageBox(NULL"The Index Is!"LbIndexStringMB_OK MB_USERICON);
                            }
                        }
                    }
                    break; 
    How do I conver Index to a string so I can show the index in a msg box?

  2. #2
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Look into:
    a) FAQ
    b) std::stringstream
    c) itoa()
    d) ultoa()
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  3. #3
    Registered User
    Join Date
    Jul 2004
    Posts
    7
    Or
    char lbText[4];
    sprintf(lbText,"%d",index);

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Code:
    char LbIndexString[512];
    SendMessage(hwndList,LB_GETTEXT,index,(WPARAM)LbIndexString);

  5. #5
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Not sure why it put a space in that code. It's supposed to read (WPARAM)LbIndexString

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Recursion Revisited again, and again!
    By clegs in forum C++ Programming
    Replies: 93
    Last Post: 12-08-2007, 08:02 PM
  2. Problem with linked list ADT and incomplete structure
    By prawntoast in forum C Programming
    Replies: 1
    Last Post: 04-30-2005, 01:29 AM
  3. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  4. link list
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 12-13-2001, 05:41 AM
  5. 1st Class LIST ADT
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 11-09-2001, 07:29 PM