Small icon not working.

Hi,
I've made a icon with multiple resolutions which include the following:
16x16 - 32x32 - 48x48 - 64x64 - 128x128 - 256x256.
I add the icon to the WNDCLASSEX structure when I initializes my window. It works fine with the .exe file itself, but I don't get a icon in the window border. I've added it in the hIcon part of the structure. I also tried to add to the hIconSm varaible, but it didn't seem to have an effect.
The icons are defined in the resource.
Any suggestions to solve this problem?

Regards,

Simon H.A.
MSDN wrote:
Your application should supply groups of icon images in the following sizes:

48x48, 256 color
32x32, 16 color
16x16 pixels, 16 color

When filling in the WNDCLASSEX structure to be used in registering your window class, set the hIcon member to the 32x32 icon and the hIconSm member to the 16x16 icon. For more information about class icons, see Class Icons.

I don't know if these resolutions are required or just a suggestion but it has always worked for me. Perhaps you have an error in your code retrieving the icon handles?
Last edited on
That doesn't have an effect. Also MSDN states that it supports up to 32 bit images (24bit color + 8bit alpha). http://msdn.microsoft.com/en-us/library/ms997636.aspx
Here is how I load them:

1
2
wcex.hIcon          = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(ID_ICON));
	wcex.hIconSm        = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(ID_ICON_SMALL));


Here is my declarations:
1
2
3
//Program icons
ID_ICON ICON "icon.ico"
ID_ICON_SMALL ICON "small.ico"


1
2
3
//Icons
#define ID_ICON 0
#define ID_ICON_SMALL 1 
You could try using LoadImage instead?

1
2
wcex.hIcon      = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(ID_ICON),IMAGE_ICON,32,32,0);
wcex.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(ID_ICON),IMAGE_ICON,16,16,0);



Here I've assumed you have a single icon file (ID_ICON ICON "icon.ico") with multiple images, as stated in orig post.

Andy

P.S. You could also query for "16" AND "32" using GetSystemMetrics with SM_CXICON/SM_CYICON and SM_CXSMICON/SM_CYSMICON
Last edited on
Got it to work. For some weird reason, I had a line of code somewhere else, where it initialized the small icon to standard. I removed it, and now it works fine.

Thanks for your support,

Simon H.A.
Topic archived. No new replies allowed.