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:
SetIcon(wxICON(aaaaa_logo));
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.
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
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):
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);
}
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]
It works for me; without an sample program with the problem it is a waste of time to try duplicate the problem.
Tim S
I used C::B Wizard using these options.
File -> New -> Project
wxWidgets Project
2.8.x
GUI none
App type: Frame
The wizard made this code method
bool TestFrameIconApp::OnInit()
{
TestFrameIconFrame* frame = new TestFrameIconFrame(0L, _("wxWidgets Application Template"));
frame->SetIcon(wxICON(aaaa)); // To Set App Icon
frame->Show();
return true;
}
bool TestFrameIconApp::OnInit()
{
TestFrameIconFrame* frame = new TestFrameIconFrame(0L, _("wxWidgets Application Template"));
frame->SetIcon(wxICON(aaaa)); // To Set App Icon //AND THIS PIECE OF CODE WAS NOT THERE IN MY CASE
frame->Show();
return true;
}
Thank you very much for solving the problem in simple and elegant way. The piece of code was not there in my "...App.cpp" but instead it was inserted by wxSmith in "...Main.cpp", which I posted earlier. Inserting the line of code by hand in my "...App.cpp" solved all my problem like magic.
My generated code was "myIconTestApp.cpp":
#include "myIconTestApp.h"
//(*AppHeaders
#include "myIconTestMain.h"
#include <wx/image.h>
//*)
IMPLEMENT_APP(myIconTestApp);
bool myIconTestApp::OnInit()
{
//(*AppInitialize
bool wxsOK = true;
wxInitAllImageHandlers();
if ( wxsOK )
{
myIconTestFrame* Frame = new myIconTestFrame(0);
Frame->SetIcon(wxICON(aaaa)); // this was inserted and everything worked fine
Frame->Show();
SetTopWindow(Frame);
}
//*)
return wxsOK;
}
So question is
#why this line of code was not generated automatically when wxSmith was used?
#why do wxSmith inserted wxFrame->SetIcon("someicon.ico") in "...Main.cpp" instead of "...App.cpp"?
#why SetIcon in "...Main.cpp" is not working while another way around is?
Well... this will be another topic of discussion (or newbie like me needs some learning to do) but my problem in hand is solved.
Thank you very much and Regards!