Solved

How do I change the 16x16 dialog icon?

Posted on 2004-04-17
20
478 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
Comment Utility
AfxGetMainWnd()->SetIcon()
0
 
LVL 4

Expert Comment

by:caner_elci
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 4

Expert Comment

by:caner_elci
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
OK
0
 
LVL 4

Accepted Solution

by:
caner_elci earned 70 total points
Comment Utility
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
Comment Utility
It works.  Thanks very much.
0
 
LVL 4

Expert Comment

by:caner_elci
Comment Utility
Anytime...
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
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…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 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

14 Experts available now in Live!

Get 1:1 Help Now