Load Gif file from the current location

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.
Post Reply
dermayank
Knows some wx things
Knows some wx things
Posts: 30
Joined: Fri Jan 22, 2021 8:56 am

Load Gif file from the current location

Post by dermayank »

I'm using wxAnimationCtrl in my application to load gif file. Currently I'm providing the full path to the gif file location. It works fine in my system but when I'm running executable in some other system I'm receiving an error stating gif file not found.

How should I load gif file in my application, such that it is automatically loaded in all systems.

I also tried converting gif file to xpm format and now 20 .xpm files are generated for each frame. I don't know how to load all to .xpm files and show animation frame by frame.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Load Gif file from the current location

Post by doublemax »

Use one of the paths returned by wxStandardPaths and use it to build an absolute path:
https://docs.wxwidgets.org/trunk/classw ... paths.html

E.g. you can get the directory the executable lies in with:

Code: Select all

#include <wx/stdpaths.h>
#include <wx/filename.h>

wxString exeDir = wxStandardPaths::Get().GetExecutablePath().BeforeLast( wxFileName::GetPathSeparator() );
wxLogMessage("exe dir: %s", exeDir);
Use the source, Luke!
Post Reply