A question about Window icon vs application icon Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
xtc
In need of some credit
In need of some credit
Posts: 8
Joined: Sat Oct 20, 2018 5:40 pm

A question about Window icon vs application icon

Post by xtc »

I have just started playing with wxWidget recently so I am asking a newbie question. My question is specific to MSW.

As I have observed, when creating a top level window (eg: wxFrame), the window icon is initialized to that of the default application icon even when the icon associated with the application has been changed. So, if I wanted to keep use the same icon for both the application (as displayed by windows) and the window title bar, I have to take an extra step to SetIcon() during the window creation step.

My question is whether this has been a design decision that has been made for some good reason. :D

From a user perspective, it seems logical to prefer to identify both the window and the application using the same icon. If this is the case, then would it not make sense to always use the same application icon for the title bar of all top level windows? And if there is a reason to show a different icon on the title bar of the window, then one can take an extra step to change icon by calling SetIcon().

I would appreciate any feedback from the experts here.

Thank you!
Manolo
Can't get richer than this
Can't get richer than this
Posts: 827
Joined: Mon Apr 30, 2012 11:07 pm

Re: A question about Window icon vs application icon

Post by Manolo »

MSW uses a resource file (.rc). You must add it to your project, compile and link it.
Take a look at yourwxdir\samples\sample.rc You'll find some explanations:
Explorer, the task bar, and others from MSW, uses the alphabetic first icon available, while wxFrame::SetIcon() uses any named icon.

Be aware that you can use many icons provided with wxWidgets, by using #include "wx/msw/wx.rc" in your own .rc file. So, your app will incorporate many icons. To be sure that the app-icon is the first, start its name with "a" like this:

Code: Select all

aaMyAppIconName ICON "iconfilename.ico"
Of course you can use this same name (aaMyAppIconName) for your wxFrame::SetIcon().
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: A question about Window icon vs application icon

Post by PB »

I also suggest not calling SetIcon() and using SetIcons() instead, provided you actually have your icon in multiple resolutions. See the SetIcons() docs and e.g. this post for reasons why.
xtc
In need of some credit
In need of some credit
Posts: 8
Joined: Sat Oct 20, 2018 5:40 pm

Re: A question about Window icon vs application icon

Post by xtc »

Thank you guys for yr informative response.

I have a followup question regarding how icons for an application/program and its associated top-level window should be handled.

In general, I think there the top level window should always use the same icon associated with the application.
As such, I think the window class should be configured with the application's icon assigned to it.
This way, when a top level windows is created, it will always display the same icon associated with the application.
Does this line of thinking make any sense?

If there is a reason to display or show a different icon, one can always invoke SetIcon/SetIcons to assign a different icon to the window after it has been created.
Post Reply