Menu

WxWidgets loading icon

2004-07-22
2012-09-26
  • Nobody/Anonymous

    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

     
    • Nobody/Anonymous

      Hi!
      Using wxICON() on Windows will load a resource, so add the icon to the rc file.

      upCASE

       
    • Nobody/Anonymous

      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

       
    • Guru Kathiresan

      Guru Kathiresan - 2004-07-23

      Try to Convert the ICON to XPM and then include the XPM Bitmap variable. This should work without any hitch.

      -Guru

       
    • Nobody/Anonymous

      how Do i convert the icon to xpm?

      also the documentation at wxwidgets.com says this should work for ico files.

      mikecoon

       
    • Nobody/Anonymous

      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

       
    • Nobody/Anonymous

      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

       
    • Nobody/Anonymous

      Ray,
         btw, your method works. And it does not require a resource file. How come this way does not require a resource file?
      mikecoon

       
    • Nobody/Anonymous

      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

       
      • Guru Kathiresan

        Guru Kathiresan - 2004-07-26

        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

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.