Page 1 of 1

Beginner - Icon trouble! [SOLVED]

Posted: Sun Jun 15, 2008 7:30 pm
by Double Trouble
Hi!
I'm a complete beginner with WxWidgets. I just build it yesterday but so far I really like what I see!

I followed this tutorial, just for fun trying to create an icon:
http://zetcode.com/tutorials/wxwidgetst ... tprograms/

I don't have the web.xpm so I just grabbed another xpm-file (mondrian.xpm) from WxWidget sample-folder and I put it in my working directory. And in the code I change from SetIcon(wxIcon(wxT("web.xpm"))) to SetIcon(wxIcon(wxT("mondrian.xpm"))). Anyways, here is the code:

Code: Select all

//icon.h
#include <wx/wx.h>

class Icon : public wxFrame
{
public:
    Icon(const wxString& title);

};

Code: Select all

//main.h
#include <wx/wx.h>

class MyApp : public wxApp
{
  public:
    virtual bool OnInit();
};

Code: Select all

//icon.cpp
#include "icon.h"


Icon::Icon(const wxString& title)
       : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(250, 150))
{
  SetIcon(wxIcon(wxT("mondrian.xpm")));
  Centre();
}

Code: Select all

//main.cpp
#include "main.h"
#include "icon.h"

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{
    Icon *icon = new Icon(wxT("Icon"));
    icon->Show(true);

    return true;
}
Thank you in advance!
/DT

Posted: Sun Jun 15, 2008 8:54 pm
by Jorg
What exactly is your problem? It is nice that you list code and point out it missed an XPM, but what is your problem?

- Jorgen

Posted: Sun Jun 15, 2008 9:12 pm
by Double Trouble
Jorg wrote:What exactly is your problem? It is nice that you list code and point out it missed an XPM, but what is your problem?

- Jorgen
When I run the program, there is no icon! Like this:

Image

When I would like to have an icon up to left like this:

Image

I hope you understand my problem now!
Thank you for answering!

/DT

Posted: Mon Jun 16, 2008 3:07 pm
by Double Trouble
The problem is now solved with help from BrianHV @ #wxwidgets. The solution was that I had to call wxInitAllImageHandlers() in OnInit!

Thanks!