How to Change the Icon of MFC application?

5 04 2009


When you create an MFC application, did you notice the icon of executable? Yes! its that same old icon. But I’ve seen other application with different icon. Well, how to set the icon of executable to give a new face for it? 😉

setappicon
Image Courtesy – Flickr


The secret is, windows will choose the first icon present in executable as exe icon. By default for an MFC application, IDR_MAINFRAME will be the icon resource name and it have the lowest resource value – 128. Follow the steps to add an icon and make set it the first one in executable.

1. Import a new icon by using resource editor.

setappicon1

2. Let the icon be IDR_ICON1.
3. Now open resource.h and you can see, IDR_MAINFRAME which is the mfc icon, have lowest resource id.

setappicon2
4. Now edit the resource.h to make IDI_ICON1 as lowest resource id.

setappicon3
5. Now clean and build your application and check the application icon. Wow! its changed!!!


The point is, the icon should be the first icon in executable. You can set icon value even to zero. It will work!


Targeted Audiance – Intermediate.

Advertisements

Actions

Information

5 responses

8 04 2009
Torin

There’s an easier way.
Just replace your app.ico file with what ever icon file you want.
It even takes care of the multiple-size, 32-bit vista/xp icon as well. 🙂

8 04 2009
Jijo.Raj

Thats Cool! Well, i just want to stress the point – System will select the first icon embudded in executable – which make more sense to non-mfc windows programmers.

Thanks for sharing it.

Regards,
Jijo.

25 06 2009
Ray Anderson

Thanks for this!

Worked it for a while before I found the answer on google. Brought me right here.

Great info!

R

12 10 2009
Mohit

Thanks for sharing the useful information

12 10 2009
Jijo.Raj

Always Welcome, Mohit!

Best Regards,
Jijo.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s




%d bloggers like this: