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!
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).