Solved

Problem displaying the correct icon !

Posted on 1998-10-06
11
184 Views
Last Modified: 2013-11-20
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
Comment
Question by:mike_marquet
  • 3
  • 3
  • 2
  • +2
11 Comments
 
LVL 3

Expert Comment

by:Norbert
ID: 1322989
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
 

Author Comment

by:mike_marquet
ID: 1322990
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
 
LVL 8

Accepted Solution

by:
Answers2000 earned 10 total points
ID: 1322991
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
 
LVL 8

Expert Comment

by:Answers2000
ID: 1322992
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
 
LVL 8

Expert Comment

by:Answers2000
ID: 1322993
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 3

Expert Comment

by:plaroche
ID: 1322994
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
 
LVL 3

Expert Comment

by:Norbert
ID: 1322995
plaroche, you say what I meant
0
 

Expert Comment

by:umarama
ID: 1322996
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
 

Author Comment

by:mike_marquet
ID: 1322997
Thanks to Norbert & Plaroche.
It works. I have forgotten to change the 16*16 icon.
0
 
LVL 3

Expert Comment

by:plaroche
ID: 1322998
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
 
LVL 3

Expert Comment

by:Norbert
ID: 1322999
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

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now