i am learning wxWidgets and i am trying to load my own icon called MRLC.ico. Here is the code in the frame constructor.
// set the frame icon
SetIcon(wxICON("MRLC.ico"));
my question is where do i have to store my icon for the setIcon to load my icon?
mikecoon
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A few months ago I had the same problem as you. I could not figure out how to load icons from a resource file, so I posted a question here and "googled" the topic to death. Got some ideas and program samples from the web, this helped.
However, I had to settle for loading the icons from the application's working directory via the SetIcon command shown in the post above. Also figured out how to convert ico to xpm format and how to use xpm files in a program.
Almost drove me nuts, but at least I learned something. Still have to figure out how to use resource files.
Ray
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'll be adding ICON to XPM conversion tool to the wxWidgets designer for Dev-C++. Currently I'm merging my wxwidgets designer into the main Dev-C++ Code. After I finish merging, I will add the support to ICON to XPM.
-Guru Kathiresan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i am learning wxWidgets and i am trying to load my own icon called MRLC.ico. Here is the code in the frame constructor.
// set the frame icon
SetIcon(wxICON("MRLC.ico"));
my question is where do i have to store my icon for the setIcon to load my icon?
mikecoon
Hi!
Using wxICON() on Windows will load a resource, so add the icon to the rc file.
upCASE
okay. i tried that.
here is my resource.h file:
// for personal icon
#define ID_MRLC_ICON 101
here is my resource.rc file
#include "resource.h"
ID_MRLC_ICON ICON "MRLC.ico"
and here is the code in frame constructor
// set the frame icon
SetIcon(wxICON(ID_MRLC_ICON));
, yet it does not load the icon at all. Where must the icon actually be saved at? My icon MRLC.ico is saved in the same directory as the .cpp file.
mikecoon
Try to Convert the ICON to XPM and then include the XPM Bitmap variable. This should work without any hitch.
-Guru
how Do i convert the icon to xpm?
also the documentation at wxwidgets.com says this should work for ico files.
mikecoon
I used the following code in my application:
SetIcon(wxIcon(wxT("myapp.ico"), wxBITMAP_TYPE_ICO));
You can use a utility called ImageMagick to convert ico files to xpm format. Both methods worked fine for me.
Ray
Ray,
Now where do you have to place your .ico file for the code to work? How does the ciode know where to look for the .ico file?
mikecoon
Ray,
btw, your method works. And it does not require a resource file. How come this way does not require a resource file?
mikecoon
Mike,
A few months ago I had the same problem as you. I could not figure out how to load icons from a resource file, so I posted a question here and "googled" the topic to death. Got some ideas and program samples from the web, this helped.
However, I had to settle for loading the icons from the application's working directory via the SetIcon command shown in the post above. Also figured out how to convert ico to xpm format and how to use xpm files in a program.
Almost drove me nuts, but at least I learned something. Still have to figure out how to use resource files.
Ray
I'll be adding ICON to XPM conversion tool to the wxWidgets designer for Dev-C++. Currently I'm merging my wxwidgets designer into the main Dev-C++ Code. After I finish merging, I will add the support to ICON to XPM.
-Guru Kathiresan