Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • Last Modified:

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 ?
0
mike_marquet
Asked:
mike_marquet
  • 3
  • 3
  • 2
  • +2
1 Solution
 
NorbertCommented:
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.

0
 
mike_marquetAuthor Commented:
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 !
0
 
Answers2000Commented:
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

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Answers2000Commented:
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
0
 
Answers2000Commented:
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
0
 
plarocheCommented:
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.
0
 
NorbertCommented:
plaroche, you say what I meant
0
 
umaramaCommented:
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 ?
0
 
mike_marquetAuthor Commented:
Thanks to Norbert & Plaroche.
It works. I have forgotten to change the 16*16 icon.
0
 
plarocheCommented:
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.


0
 
NorbertCommented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now