Original Post
I''ve got a listbox I fill as such:
int index = SendDlgItemMessage(hwnd, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)str.c_str());
SendDlgItemMessage(hwnd, IDC_LIST, LB_SETITEMDATA, (WPARAM)index, (LPARAM)str.c_str());
Where str is a std::string. The first works fine, and the string is displayed. The second, where I attempt to set the internal value of that element, doesn''t seem to take. It works however if I use a literal string like (LPARAM)"string". It fills properly and I can retrieve it later with an LB_GETITEMDATA message. Yet when I use c_str() or even manually convert the string to just char * and attempt to cast it doesn''t work either. How can this work fine in one line and not in the next? Isn''t it the same exact cast?