Problem!

Discussion in 'Win32' started by Kasya, Aug 10, 2008.

  1. Kasya

    Kasya New Member

    Joined:
    Feb 21, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hello

    Code:
     
    unsigned int idx;
            LPSTR itemData;
     
            idx = SendDlgItemMessage(hWnd, BONENAMES, LB_GETCURSEL, 0, 0);
     
            if(idx != -1) {
                int iResult = SendDlgItemMessage(hWnd, BONENAMES, LB_GETITEMDATA, idx, (LPARAM)itemData);
    //itemData = SendDlgItemMessage(hWnd, BONENAMES, LB_GETITEMDATA, idx, 0); Not Works too.
            }
     
            MessageBox(NULL, itemData, "Selected Item:", MB_OK);
    
    The Message Box Shows Empty. Why?
    Thanks in Advance!
     
  2. imported_xpi0t0s

    imported_xpi0t0s New Member

    Joined:
    Jul 18, 2008
    Messages:
    101
    Likes Received:
    0
    Trophy Points:
    0
    See http://msdn.microsoft.com/en-us/library/aa929823.aspx

    Setting itemData in lParam is pointless because this is ignored.
    LB_GETITEMDATA returns the 32-bit value associated with the selection, NOT the text from the listbox.
    So if you associate "one" with 1, "two" with 2 and "three" with 3, and the user selects "two", then LB_GETITEMDATA will return 2. This is an integer, not a string, so cannot be displayed directly with MessageBox; you would need to convert it to a string first (e.g. with sprintf).
     
  3. Kasya

    Kasya New Member

    Joined:
    Feb 21, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Thanks!
    I found it to do with LG_GETTEXT
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice