I'm a little noob at C++ and even more at wxWidgets, so I'm doing a few things to learn both at the same time.
Basically I want to load a list with an animated gif right next to a text. I was using this example , but when I try to load the images it says "Couldn't add an image to the image list".
This is the code
Code: Select all
std::string sprites_path = (boost::filesystem::current_path().string()) + "\\sprites";
if(boost::filesystem::exists(sprites_path) && boost::filesystem::is_directory(sprites_path)) {
boost::filesystem::directory_iterator dir_iter(sprites_path);
boost::filesystem::directory_iterator dir_iter_;
boost::filesystem::path boost_path;
wxInitAllImageHandlers();
wxImageList* imgList = new wxImageList();
int id = 0;
for(; dir_iter != dir_iter_; ++dir_iter) {
if(boost::filesystem::is_regular_file(dir_iter->status())) {
wxImage img(dir_iter->path().string(), wxBITMAP_TYPE_GIF);
// img.AddHandler(new wxGIFHandler);
imgList->Add(img);
wxListItem item;
item.SetId(id);
item.SetText(dir_iter->path().filename().string());
listCtrl->InsertItem(item);
id++;
}
}
listCtrl->SetImageList(imgList, wxIMAGE_LIST_NORMAL);
}
Any suggestions? Actually, like I said, this is just for learning, so I will take any suggestions.
Thanks in advance!