Link to home
Start Free TrialLog in
Avatar of mike_marquet
mike_marquet

asked on

Problem displaying the correct icon !

I have a problem to display the correct icon
when I look to the executable file with the explorer (or when I create a shortcut to executable file). The system
displays me the MFC icon which is generated when you create a new application with visual C++ 5.0 instead of
my icon.

I have change the MFC icon (IDR_MAINFRAME) in the resource.

When I create a shortcut on the desktop, the system displays me the correct one. When I look in the executable file after icons (with change icon), I have only one icon (my icon).

What must I do for displaying the correct icon ?
Avatar of Norbert
Norbert
Flag of Germany image

did you remember that there are 2 Icons ?
a 32 X 32 Icon and a 16 X 16 Icon
You can select the Icon to change using the combobox that is labeled Device inside the recource editor.

Avatar of mike_marquet
mike_marquet

ASKER

No, this is correct. I use SetIcon(IDR_MAINFRAME, TRUE) with a 32*32 resource icon.
I suppose that I must register my window application !
ASKER CERTIFIED SOLUTION
Avatar of Answers2000
Answers2000

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The algorithm used to determine the icon used (as far as I can tell) is:

A. RUNTIME
When you're program is running the icon used in Top Left of your Window (and in task bar) is

A1. Get the icon associated with the top level window
A2. If none is found using A1, then check for icon associated with the Window class

Most MFC programs use A1.  As your Q makes it sound as if the runtime behaviour is correct, this implies you have done A1 correctly.


B. SHELL/EXPLORER
B1. Explorer will use the _first_ icon in your EXE when it sees it on the desktop.  The _first_ icon is the lowest one defined in your resources.
B2. Explorer will use the icon associated with your documents for document files.  An icon type can be registered per file extension.

If I understand correctly, you are having problems with B1 (?).  Do this:
(a) Exit VC, save the project
(b) Open the .RC file in a text editor (notepad or edit).  make sure the correct icon is the first one listed [re-order the lines listing the ICONs).  Save the file and exit
(c) open the RESOURCE.H file in a text editor.  Reorder the icon ids (IDI_WHATEVER usually) by swapping the values #define'd for each one.  Make sure the icon you want has the lowest id number. Save and exit
(d) Recompile everything
Oops that was meant to be a comment (sorry for double entry)

Oh well, reject it if it's no help, accept it if it's okay
On the desktop a 32x32 icon is found in your exe file. It is that one that is shown.

In the explorer you usually see the 16x16 icon, this is the one you must have forgotten to modify. Open the resource editor and edit the IDR_MAINFRAME icon, you will see the 32x32 one, check for a combobox and it offers you the possibility to edit the 16x16 one.
plaroche, you say what I meant
I recently encountered this problem. I had solved it exactly the way Answers2000 has mentioned above. Is it possible for Answers2000 to let me know if this is documented ?
Thanks to Norbert & Plaroche.
It works. I have forgotten to change the 16*16 icon.
Norbert should have had the points, you should not have given them to Answers2000.
What you should've done was ask Norbert to answer back again and give him the points.


plaroche, you are right
That is something that happens often
but I think you should have the points because I was not
clear enough in my answer and  mike_marquet did not understand what I meant