Beginner - Icon trouble! [SOLVED] Topic is solved

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
Double Trouble
Knows some wx things
Knows some wx things
Posts: 26
Joined: Sat Jun 14, 2008 12:42 pm
Location: Sweden
Contact:

Beginner - Icon trouble! [SOLVED]

Post 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
Last edited by Double Trouble on Mon Jun 16, 2008 3:02 pm, edited 1 time in total.
Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post 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
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Double Trouble
Knows some wx things
Knows some wx things
Posts: 26
Joined: Sat Jun 14, 2008 12:42 pm
Location: Sweden
Contact:

Post 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
Double Trouble
Knows some wx things
Knows some wx things
Posts: 26
Joined: Sat Jun 14, 2008 12:42 pm
Location: Sweden
Contact:

Post 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!
Post Reply