I don't seem to get any errors if I call SetItemText(item,subItem,string)
, on a value of subItem greater than the number of columns set up. But I don't seem to be getting the data back when I call GetItemText. Just wanted to check that's correct, and I can't use SetItemText as a more convenient way to add s开发者_开发知识库ome custom data - SetItemData requires you remember to deallocate memory and so on.
I think you'll have to resort to the SetItemData
method although you seem to be afraid of the memory allocation/deallocation.
Why don't you override the CListCtrl
class with your own class (e.g. CMyListCtrl
) in which you implement e.g. a SetItemCustomData
method and which handles all the memory issues for you, so you don't have to deal with that in your actual user interface code?
Did you check that you can get the text back?
Even if it works, I would absolutely avoid this kind of solution: You can't predict if it will still work in the next version of Windows. Or even if it worked in all the previous ones.
Use SetItemData()... and don't forget to free the memory!
精彩评论