If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
- Part Of The Furniture
- Posts: 5154
- Joined: Sat Apr 16, 2005 7:22 am
- Location: USA, Ukraine
1. Is this proper/legitimate way:
Code: Select all
m_myListBiox = new wxListBix( ... );
wxString test = "data";
m_myListBox->Append( "String1", &test );
2. If the code is correct - how do I get back the "data"?
I know I should use pointer to set the client data, but its just an overkill for such simple case.
- Posts: 16014
- Joined: Fri Apr 21, 2006 8:03 pm
- Location: $FCE2
If you use the overload that takes a "void*", the object must be allocated on the heap and you're responsible for deleting it.
If you use the overload that takes a "wxClientData*", the object must also be allocated on the heap but the listbox takes ownership and deletes it.
If you only want to store a string, you can use wxStringClientData.
https://docs.wxwidgets.org/trunk/classw ... _data.html
You get the object back using wxItemContainer::GetClientObject()
https://docs.wxwidgets.org/trunk/classw ... 171e7fb98c
Use the source, Luke!