Load animated gif on wxListCtrl

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
emartinez
In need of some credit
In need of some credit
Posts: 5
Joined: Fri Dec 26, 2014 1:28 am

Load animated gif on wxListCtrl

Post by emartinez »

Hello! I'm new in the forum.

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);
    }
Anyway when I build and run this it takes a while to load even when it fails, so apparently this is not the best approach.

Any suggestions? Actually, like I said, this is just for learning, so I will take any suggestions.

Thanks in advance!
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Load animated gif on wxListCtrl

Post by doublemax »

Not possible. None of the list controls support animated images.
Use the source, Luke!
emartinez
In need of some credit
In need of some credit
Posts: 5
Joined: Fri Dec 26, 2014 1:28 am

Re: Load animated gif on wxListCtrl

Post by emartinez »

Well then, I'll have to look for another approach!

Thanks for your answer!
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Load animated gif on wxListCtrl

Post by doublemax »

What exactly do you need to do? If it's just for displaying a list (without editing), you could use a html control for it.

http://docs.wxwidgets.org/trunk/classwx_web_view.html
http://docs.wxwidgets.org/trunk/classwx ... indow.html
Use the source, Luke!
Post Reply