Solved

How do I change the 16x16 dialog icon?

Posted on 2004-04-17
20
485 Views
Last Modified: 2013-11-20
I have a multi-size icon (256 color) in my program.  The different sizes look similar, only with different resolutions.  I just altered the smallest icon in the resource.  The new small icon appears as the program icon in Windows Explorer, but the old icon remains in the program's title bar.

How can I make the new 16x16 icon show in the title bar?
0
Comment
Question by:Alkali_Guy
[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
  • 10
  • 9
20 Comments
 
LVL 4

Expert Comment

by:bkfirebird
ID: 10852267
AfxGetMainWnd()->SetIcon()
0
 
LVL 4

Expert Comment

by:caner_elci
ID: 10852690
Change your new icon's name to IDR_MAINFRAME, which is used by MFC app wizard by default.. Or, for example, if this is a dialog based application, in your dialogs class file (cpp) you'll see a line like this:

m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

change that icon resource name there.. You'll see the similar lines in different kind of applications (SDI, MDI)..
0
 
LVL 5

Author Comment

by:Alkali_Guy
ID: 10853612
My new icon is in IDR_MAINFRAME; I have only redrawn one of the icon sizes.  When I rebuilt the file, the title bar should show the new 16x16 icon.
0
Industry Leaders: 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 5

Author Comment

by:Alkali_Guy
ID: 10855520
Is it possible that Windows has been resizing the 32x32 icon to use as the 16x16 icon, and ignoring my 16x16 icon?
0
 
LVL 4

Expert Comment

by:caner_elci
ID: 10855528
It doesn't.. I suggest you to open your icon file with some other icon editor to be sure..
also you can delete unused icon images in a .ico file.. just open the icon to be deleted, and select Delete Device Image from Image menu..
0
 
LVL 5

Author Comment

by:Alkali_Guy
ID: 10855641
I can't find the old 16x16 icon in any device image in my project.  I've tried cleaning and rebuilding my project, and drawing the icon in a new device image.  And yet it keeps appearing in the title bar and taskbar.
0
 
LVL 4

Expert Comment

by:caner_elci
ID: 10855659
Are you sure you are executing the right version? I suggest you to do things in operation system level.. close your project.. go your projects directory, check all .ico files over there, and see their content by a icon editor.. then remove Debug and Release directories.. then open your project again, and build it..
0
 
LVL 5

Author Comment

by:Alkali_Guy
ID: 10855881
Sorry, I know I am running the right version, because the new 16x16 icon is visible when Windows Explorer shows the build folder in List view.
0
 
LVL 4

Expert Comment

by:caner_elci
ID: 10855890
Well, then I think there are two things to do..

1. Try removing your icon file and IDR_MAINFRAME resource, and recreate an icon named IDR_MAINFRAME..
or
2. Try recreating your project

That's all I can think.. Sorry..
0
 
LVL 5

Author Comment

by:Alkali_Guy
ID: 10855903
I carefully compared the icon in the title bar with my old 16x16 icon file.  The two are slightly different.  This means that Windows has been resizing my 32x32 icon to get the icon in the title bar.

How can I force Windows to use the new 16x16 icon that I drew?
0
 
LVL 4

Expert Comment

by:caner_elci
ID: 10855914
Why don't you just delete 32x32 icon using Tools|Delete Device Image? Try that way, if it works well, try creating a new 32x32 icon?
0
 
LVL 5

Author Comment

by:Alkali_Guy
ID: 10855960
I deleted and recreated the whole icon resource.  It is still a multi-size icon with 256 colors.  The 16x16 icon is still a miniature version of the 32x32 icon!

I don't know if it matters; all three sizes use a palette saved by Paint Shop Pro.
0
 
LVL 5

Author Comment

by:Alkali_Guy
ID: 10855970
Even if I delete the 32x32 pixel device image, Windows cleverly resizes the 48x48 pixel image to 16x16 and uses that.
0
 
LVL 4

Expert Comment

by:caner_elci
ID: 10855977
I don't think color palette matters.. but anyway, you should give it a try.. you can remove the current icon again, and just draw some lines in Visual Studio's icon editor.. then rebuild and see what happens..
0
 
LVL 5

Author Comment

by:Alkali_Guy
ID: 10855989
I guess this is a bug; Windows or the compiler won't use a 16x16 icon in the title bar.  ...Unless none of the icons use 256 colors?
0
 
LVL 4

Expert Comment

by:caner_elci
ID: 10855999
I don't think it's about compiler.. You know, the compiler just adds your icon as a resource in your exe file or dll.. It's about Windows.. Anyway, let me try if it works..
0
 
LVL 5

Author Comment

by:Alkali_Guy
ID: 10856012
OK
0
 
LVL 4

Accepted Solution

by:
caner_elci earned 70 total points
ID: 10856035
Well, here is the result:

I created one 256 color 16x16 icon and one 256 color 32x32 icon.. It shows resized 32x32 in title bar, as you say..
I added one 16 color 32x32 icon, nothing changed..
I added one 16 color 16x16 icon, nothing changed..

and I found this code, in OnInitDialog of my application :)

      // Set the icon for this dialog.  The framework does this automatically
      //  when the application's main window is not a dialog
      SetIcon(m_hIcon, TRUE);                  // Set big icon
      SetIcon(m_hIcon, FALSE);            // Set small icon

And when I commented second SetIcon line there, it worked well.. now I can see my 16x16 256 color icon in title bar..
Change those lines to:

      SetIcon(m_hIcon, TRUE);                  // Set big icon
      //SetIcon(m_hIcon, FALSE);            // Set small icon

and try again, let's see what happens..
0
 
LVL 5

Author Comment

by:Alkali_Guy
ID: 10856205
It works.  Thanks very much.
0
 
LVL 4

Expert Comment

by:caner_elci
ID: 10857031
Anytime...
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Suggested Solutions

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.

739 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