Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem displaying the correct icon !

Posted on 1998-10-06
11
Medium Priority
?
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 30 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

604 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