User forums > General (but related to Code::Blocks)

Setting Application Icon How To?

(1/2) > >>

d88pak:
Hi,

I don't know where the problem lies so I posted on both forums. So far I was not able to get any answer from wxWidgets forum.

I am using:
========================
c::b = 8.02 (without mingw)
MinGW = 3.4.5
wxWidgets = 2.8.8
OS = WindowsXP/SP2
wxSmith as from designer
========================

My application is compiling and working fine but with small problem. The "SetIcon" is not showing the icon on titlebar area of my application.

Details of my problem which I am facing after I posted this problem is here in wxWidgets forum
http://wxforum.shadonet.com/viewforum.php?f=1&sid=86139d894968630872658e38b2b63b91

searching this forum, I stumbled here
http://forums.codeblocks.org/index.php/topic,2191.0.html


--- Quote ---Making the same icon show up in the upper left corner of your program window and in the taskbar is somewhat more complicated.

by TDragon

--- End quote ---

caught my attention. This means its not a new issue.

Please can somebody explain to me where the problem lies (windows, mingw, wxwidgets, c::b settings etc) and  how to solve it?

Thanks

Jenna:
SetIcon() works for me (at least for framebased apps).

I have an icon-file called "aaaaa_logo.ico" in the projects root-dir.

In the resource-file ("resource.rc" if created by the wizard) I replace the first line (aaaa ICON "wx/msw/std.ico") with aaaaa_logo ICON "aaaaa_logo.ico"

In the constructor I added this line:

--- Code: --- SetIcon(wxICON(aaaaa_logo));

--- End code ---

And that's it.

You might need to place "#include <wx/icon.h>" in your .cpp file

EDIT:

I only tested it on w2k, I normally do not develop on windows (except for web-development and embedded development on beckhoff-components).
But I think it should work on XP also.

d88pak:

--- Quote ---In the resource-file ("resource.rc" if created by the wizard) I replace the first line (aaaa ICON "wx/msw/std.ico") with aaaaa_logo ICON "aaaaa_logo.ico"
--- End quote ---

I had tried replacing "std.ico" with my own as you said before but running the application shows the icon in taskbar not in the frame window.

I have also tried using icon (absolute path) from wxSmith property window which used to work before but not anymore now.

Most weired thing happned to me now is, even if icon file is embedded in app through rc file, I can see the std.ico in my taskbar.

currently I am checking what codes wxSmith changes automatically. I found out that when I try to set/unset the frame icon from wxSmith's properties, it adds and removes <wx/bitmap.h> and <wx/image.h> respectively.  I noticed this particular bihavior because my application failed to compile when I removed the  frame image (set to no image) since I have other Static bitmap controls in my frame which depends on <wx/bitmap.h> and <wx/image.h> but removed automatically by wxSmith. I guess its the bug in wxSmith failing to check if other dependent controls are present before removing the header file.

I am suspecting wxSmith for this but don't know where to look for. Any clue regarding this?

Thanks

stahta01:
Do you have an short code sample that runs and that shows the problem?

That is the only way I get wxWidgets questions answered; I usual start out with the wxWidgets sample closest to my program and add code till the problem happens.

Tim S

d88pak:

--- Quote ---Do you have an short code sample that runs and that shows the problem?

That is the only way I get wxWidgets questions answered; I usual start out with the wxWidgets sample closest to my program and add code till the problem happens.

Tim S

--- End quote ---

I tried creating new wxFrame based Hollow app (from wizard monolithic=1, unicode=1, dynamic liking=1, wxwidget version 2.8.x) and tried setting icon from its properties. Still the same same problem. Nothing is done here yet by hand (all generated code).

Probably the relevant code will be (which is generated by wxSmith):


   
--- Code: --- Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
    {
    wxIcon FrameIcon;
    FrameIcon.CopyFromBitmap(wxBitmap(wxImage(_T("D:\\CODE_BLOCKS_WORKSPACE\\myIconTest\\res\\myicon.png"))));
    SetIcon(FrameIcon);
    }

--- End code ---

NOTE: I have tried ICO file also without any progress.

I had posted my intentional code at wxWidgets forum. Please follow the link in my previous post.

For clarity, I had attached two images for reference.

Thanks




[attachment deleted by admin]

Navigation

[0] Message Index

[#] Next page

Go to full version