Click here to Skip to main content
13,051,502 members (62,699 online)
Click here to Skip to main content
Add your own
alternative version


24 bookmarked
Posted 16 Feb 2000

Replacing the Default MFC Icon

, 16 Feb 2000
Rate this:
Please Sign up or sign in to vote.
How to replace the default MFC icon in your application.

Many fresh MFC programmers wonder how to 'replace' the default icon rather than to change or edit in the resourc editor. Here are two simple ways to do this (actually one method but two versions).

  1. There is an ICON statement in the resource (.rc) file that causes the resource compiler to include the icon in the program's resources. The default icons for MFC projects are placed in ../res folder. To replace these icons we need to edit rc file and supply new icons for the existing ones. Proceed as follows:

    1. Copy the new icon file in .../res folder. This step is not essential but its better to put all the resources in one folder.
    2. Select File -> Open and File Open Dialog popups. Select the .rc file and change the 'open as' combo box to 'text' (which is 'auto' by default) in the File -> Open Dialog box. Now Look for the ICON statement in the .rc file, which should look like:
    // Icon 
    // Icon with lowest ID value placed first to ensure application icon
    // remains consistent on all systems.
    IDR_MAINFRAME           ICON    DISCARDABLE     "res\\Project.ico"
    IDR_DEVICETYPE          ICON    DISCARDABLE     "res\\ProjectDoc.ico"

    Next simply change the concerned file name with new one, e.g:

    IDR_MAINFRAME           ICON    DISCARDABLE     "res\\NewIcon.ico"

    Now build the project and the new icon should show up.

  2. The second way is the short-cut version of the first. Instead of editing the .rc file just rename the new icon to the same old icon name and copy onto it. However if you build your project, the same old (default) icon will be shown though it does not even exist on the disk now! This is because the resource compiler does not detect any changes in rc file and hence it doesn't actually recompile the .rc file (unless some change is introduced into it). As a result the program shows the same old icon which was added to it in the last compilation. Hence to take the effect, just recompile the rc file. It can simply be done by opening it as a text file (as in method 1), click in the file and compile (Ctrl+F7).

Note: Its generally not recommended to manually edit .rc file, however there is no harm with the above procedures and can be used without any fear. <p>


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Shahzad Khan
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

Questionvs2010 always Pin
steveh21125-Jul-11 17:53
membersteveh21125-Jul-11 17:53 
this is very frustrating. what even i do, edit the .ico file (in vs2010 or another editor), change to a new .ico file in resource editor, etc. vs2010 always puts the default MFC icons back in the .ico file so my changes are irrelevant.

i've tried a clean build, i've tried everything i can think of but nothing works.

any ideas please?

AnswerRe: vs2010 always [modified] Pin
steveh21125-Jul-11 18:09
membersteveh21125-Jul-11 18:09 
Question#if way? Pin
Super Garrison6-Aug-08 7:13
memberSuper Garrison6-Aug-08 7:13 
QuestionWhy the second icon not be changed? Pin
Anonymous25-Nov-04 23:21
sussAnonymous25-Nov-04 23:21 
GeneralLoad Icon from a file Pin
DosK19-Feb-03 23:12
memberDosK19-Feb-03 23:12 
QuestionWhat when i have a multi document template and need different icons Pin
Anup raje12-Oct-01 23:01
memberAnup raje12-Oct-01 23:01 
AnswerRe: What when i have a multi document template and need different icons Pin
Anonymous4-Jun-02 23:11
memberAnonymous4-Jun-02 23:11 
GeneralThis always works... Pin
Roger C25-Sep-00 13:58
sussRoger C25-Sep-00 13:58 
Generalsimple solution! Pin
Jarek31-Jul-00 15:22
sussJarek31-Jul-00 15:22 
GeneralChange it by load a Icon-file Pin
Wolfram Steinke25-Apr-00 19:07
sussWolfram Steinke25-Apr-00 19:07 
GeneralRe: Change it by load a Icon-file Pin
Shahzad Alam Khan26-Apr-00 4:24
sussShahzad Alam Khan26-Apr-00 4:24 
GeneralRe: Change it by load a Icon-file Pin
Peter Lim3-Oct-00 15:04
sussPeter Lim3-Oct-00 15:04 
GeneralRe: Change it by load a Icon-file Pin
Anonymous23-Nov-00 22:22
memberAnonymous23-Nov-00 22:22 
GeneralRe: Change it by load a Icon-file Pin
Anonymous28-Aug-01 4:47
memberAnonymous28-Aug-01 4:47 
GeneralChange it by load a Icon-file Pin
Stephan Strittmatter1-Mar-00 3:34
sussStephan Strittmatter1-Mar-00 3:34 
GeneralRe: Change it by load a Icon-file Pin
Shahzad Alam Khan2-Mar-00 3:24
sussShahzad Alam Khan2-Mar-00 3:24 
GeneralRe: Change it by load a Icon-file works! Pin
Stephan Strittmatter2-Mar-00 21:16
sussStephan Strittmatter2-Mar-00 21:16 
GeneralKia baat hai Shahzad ki Pin
Atif Anwar17-Feb-00 6:05
sussAtif Anwar17-Feb-00 6:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 17 Feb 2000
Article Copyright 2000 by Shahzad Khan
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid