Solved

How do I change the 16x16 dialog icon?

Posted on 2004-04-17
20
480 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Separate files macro - Errors on larger data set 18 65
twoTwo  challenge 35 93
mapBully challenge 6 115
Message not shown 5 33
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

895 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

13 Experts available now in Live!

Get 1:1 Help Now