Is there any way to add a string with ID in listbox??
ID shouldn't be visible but it has to be readable again (e.g. on double click).
Thanks for all answers!
Printable View
Is there any way to add a string with ID in listbox??
ID shouldn't be visible but it has to be readable again (e.g. on double click).
Thanks for all answers!
Thanks, but the same thing stopped me when I try to read this ID from listbox. On double click I send message LB_GETITEMDATA, but I don't know how to determine wParam upon the item that was double clicked...
>>how to determine wParam upon the item that was double clicked<<
LB_GETCURSEL.
OK, everything works, but the problem is, I don't get the value I assigned with LB_SETITEMDATA, but some strange characters...
Code on double click:
PS: It doesn't help if I change types of id and index to int or long int.Code:
LRESULT index = SendDlgItemMessage(hwnd, IDLB_UPORABNIKI_PREGLED_SEZNAM, LB_GETCURSEL, 0, 0);
if(index == LB_ERR)
{
MessageBox(hwnd, "Error1!", "Error", MB_OK | MB_ICONERROR);
}
else
{
LRESULT id = SendDlgItemMessage(hwnd, IDLB_UPORABNIKI_PREGLED_SEZNAM, LB_GETITEMDATA, (WPARAM)index, 0);
if(id == LB_ERR)
{
MessageBox(hwnd, "Error2!", "Error", MB_OK | MB_ICONERROR);
}
else
{
MessageBox(hwnd, (char*)id, "OK", MB_OK);
}
}
Looks like you're storing and retrieving a pointer to a string (char*) with each listbox item. If that's the case then you'll need to store those strings somewhere else with proper scope otherwise those list item pointers will be invalid and point to garbage - presumably the 'strange characters' you are referring to.
Thanks - i used array of strings (string not char*) and I made it work! :)