Replacing the Default MFC Application Icon
Many new 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:
(i). copy the new icon file in .../res folder. This step is not essential but its better to put all the resources in one folder.
(ii). 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 rc file, which should look like:
Next simply change the concerned file name with new one, e.g:
// 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"
Now build the project and the new icon should show up.
IDR_MAINFRAME ICON DISCARDABLE "res\\NewIcon.ico"
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.