Hi everyone,
I'm a brand new user, been going for all of a week, so any help would be really useful and hopefully this will be easily fixed!
i'm trying to create an icon for my frame, and following the wxWidgets book I typed:
wxIcon limeIcon;
wxBitmap bitmap(wxT("LimeIcon24_24.png"), wxBITMAP_TYPE_PNG);
limeIcon.CopyFromBitmap(bitmap);
SetIcon(wxIcon(limeIcon));
This builds but I get a "No image handler for type 15 defined" warning. I know that the type is included in the enumeration list in gdicmn.h, as well as wxBITMAP_TYPE_PNG_RESOURCE, but it isn't in any other bits of code that I can search in.
so I tried :
wxIcon limeIcon;
wxBitmap bitmap(wxT("LimeIcon24_24.bmp"), wxBITMAP_TYPE_BMP);
limeIcon.CopyFromBitmap(bitmap);
SetIcon(wxIcon(limeIcon));
which built and ran with no warnings but did not display the icon.
I'm using Windows XP and visual studio express 2010 to program in.
Any help would be most appreciated!
thanks in advance,
Gilly Ames
Creating a wxIcon from a bitmap (.bmp or .png) Topic is solved
-
- Ultimate wxWidgets Guru
- Posts: 672
- Joined: Tue Aug 31, 2010 6:22 am
- Location: Belgium
You should initialise all image handlers before trying to import images (::wxInitAllImageHandlers)
Take a look at the following link for more info : http://docs.wxwidgets.org/2.8/wx_appini ... gehandlers
Take a look at the following link for more info : http://docs.wxwidgets.org/2.8/wx_appini ... gehandlers
Thanks for the reply, have tried the Initialise all option, which did stop the warning, but the picture was still not displayed.
also corrected the line:
SetIcon(wxIcon(LimeIcon))
to just
SetIcon(LimeIcon) (since the icon was already created)
this is all done in the frame construnctor so there is no need for frame-> etc.
have now also tried the xpm route, i.e creating a .xpm file and compiling that, which also didn't work, but still not errors or warnigns in the build. am starting to suspect the size - is 24x24 not 16x16. could this be the problem?
Cheers,
Gilly Ames
also corrected the line:
SetIcon(wxIcon(LimeIcon))
to just
SetIcon(LimeIcon) (since the icon was already created)
this is all done in the frame construnctor so there is no need for frame-> etc.
have now also tried the xpm route, i.e creating a .xpm file and compiling that, which also didn't work, but still not errors or warnigns in the build. am starting to suspect the size - is 24x24 not 16x16. could this be the problem?
Cheers,
Gilly Ames
-
- Ultimate wxWidgets Guru
- Posts: 672
- Joined: Tue Aug 31, 2010 6:22 am
- Location: Belgium
I don't think the size should be a problem. What is your code for the xpm version ? It should simply be something like this :
Code: Select all
#include "my_icon.xmp"
...
SetIcon(wxIcon(my_icon_xpm));