Titlebar icon from exe?
Titlebar icon from exe?
Is there a way to change the icon on the titlebar of my main window to be the one that is embedded in the executable? I've searched the forums and google, but can't find what I'm looking for.
-
- wxWorld Domination!
- Posts: 1059
- Joined: Sun Dec 30, 2007 6:40 pm
- Location: Canada
Hi,
Pretty well every frame/dialog etc. type derives from wxTopLevelWindow, so you can call myFrame->SetIcon()
See http://docs.wxwidgets.org/stable/wx_wxt ... dowseticon
If you're using windows, you can get the same icon from your resource file.
Hope that helps,
Jim
Pretty well every frame/dialog etc. type derives from wxTopLevelWindow, so you can call myFrame->SetIcon()
See http://docs.wxwidgets.org/stable/wx_wxt ... dowseticon
If you're using windows, you can get the same icon from your resource file.
Code: Select all
frame->SetIcon(wxIcon(wxT("ICON_MAIN")));
Jim
OS: Vista SP1, wxWidgets 2.8.7.
-
- Experienced Solver
- Posts: 72
- Joined: Fri Feb 20, 2009 7:13 pm
- Location: $(#wx)\src
Icons are usually dealt with within a .rc file (Resource File) but can be implemented in a class file as well. I'll give examples of both.
This is an example implemented inside of a resource file. This is a LOT more simple than a C++ implementation.
For the C++ implementation, I'll of course use the built-in class called wxIcon.
EDIT: I completely forgot to mention that SetIcon needs to be called in both versions of this. Icon being either the location of the icon in comparison to the program itself or being the name of the icon inside the embedded resource file. In this case, the resource file gives it the name of aaaa.
This is only valid for a wxTopLevelWindow for any of these of course. The resource file is more convenient and I believe there are some other features that come with it.
Also, I've never really tried but I'm not sure if you can embed the icon in your application if you use a C++ implemented function. I may be wrong.
Code: Select all
aaaa ICON "wx/msw/std.ico"
//This is generated by Code::Blocks
#include "wx/msw/wx.rc"
For the C++ implementation, I'll of course use the built-in class called wxIcon.
Code: Select all
wxIcon icon(wxT("std.ico"), wxBITMAP_TYPE_ICO);
<toplevelwindow>->SetIcon(icon);
This is only valid for a wxTopLevelWindow for any of these of course. The resource file is more convenient and I believe there are some other features that come with it.
Also, I've never really tried but I'm not sure if you can embed the icon in your application if you use a C++ implemented function. I may be wrong.
Last edited by computerquip on Wed Feb 25, 2009 10:58 pm, edited 2 times in total.
-
- wxWorld Domination!
- Posts: 1059
- Joined: Sun Dec 30, 2007 6:40 pm
- Location: Canada