How do I change the 16x16 dialog icon?

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?
LVL 5
Alkali_GuyAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
caner_elciConnect With a Mentor Commented:
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
 
bkfirebirdCommented:
AfxGetMainWnd()->SetIcon()
0
 
caner_elciCommented:
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
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.

 
Alkali_GuyAuthor Commented:
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
 
Alkali_GuyAuthor Commented:
Is it possible that Windows has been resizing the 32x32 icon to use as the 16x16 icon, and ignoring my 16x16 icon?
0
 
caner_elciCommented:
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
 
Alkali_GuyAuthor Commented:
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
 
caner_elciCommented:
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
 
Alkali_GuyAuthor Commented:
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
 
caner_elciCommented:
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
 
Alkali_GuyAuthor Commented:
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
 
caner_elciCommented:
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
 
Alkali_GuyAuthor Commented:
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
 
Alkali_GuyAuthor Commented:
Even if I delete the 32x32 pixel device image, Windows cleverly resizes the 48x48 pixel image to 16x16 and uses that.
0
 
caner_elciCommented:
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
 
Alkali_GuyAuthor Commented:
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
 
caner_elciCommented:
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
 
Alkali_GuyAuthor Commented:
OK
0
 
Alkali_GuyAuthor Commented:
It works.  Thanks very much.
0
 
caner_elciCommented:
Anytime...
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.

All Courses

From novice to tech pro — start learning today.