PDA

View Full Version : Not sure how to add an icon


Nikolai459
07-31-2006, 03:06 PM
Hey guys,

I'm not really sure what code this is, I think it may be python but I've never really worked with it before...

I need to know how to display an icon. Right now this displays a gui window with a Title, position and size. I'm not sure exactly how to add a icon to make it work with this format.

Any help would be appreciated, thanks!

bool Pressnet::OnInit()
{
MainFrame *frame = new MainFrame("Window Title", wxPoint(50,50), wxSize(600,500) );;
CFActive=FALSE;
DBCFActive=FALSE;
initData();
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}

MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)NULL, -1, icon, title, pos, size)

I believe that the icon would go in front of the title declaration, but just not sure how to make it work. Thanks in advance!

oracleguy
07-31-2006, 06:33 PM
That looks like wxWidgets stuff. So you want have it display an icon on the title bar of the dialog?

If thats the case you can set the icon by using the wxIcon object and the SetIcon method.

Nikolai459
07-31-2006, 08:20 PM
Ya, I need to display an icon in the title bar and on the task bar also...

Do you have an example of how this would be done? Thanks.

oracleguy
07-31-2006, 08:23 PM
If you add the icon as a resource to your C++ program, you should be able to load it like below in your MainFrame constructor.


wxIcon myIcon("RESOURCE_NAME");
SetIcon(myIcon);