Windows: Setting the window icon
Again, the window will use the icon in hIconSm for the small icon. But it must meet the dimensions as indicated in that excerpt I quoted above.
quote:Original post by emileej
I have ONE icon. This one icon has TWO dimensions: 32x32 AND 16x16.
emileej, LoadIcon will only load an icon of a size that''s equivalent to the "large" icon size. to load icons of other sizes you need to use the LoadImage function, which actually superceded LoadIcon back in the ''95 days.
here''s a code snippet (keep in mind that i''m using a resource ID here so i use the MAKEINTRESOURCE macro to convert to a string pointer, whereas i *think* you''ve stored your ico into the resource using a string name, so don''t use MAKEINTRESOURCE if that''s still the case):
this will load an icon from the specified icon resource that is the closest match in size to the current "small" icon size specified for the system. you could also use this type of function call for the "large" icon; just substitute SM_CXICON for SM_CXSMICON.
here''s a code snippet (keep in mind that i''m using a resource ID here so i use the MAKEINTRESOURCE macro to convert to a string pointer, whereas i *think* you''ve stored your ico into the resource using a string name, so don''t use MAKEINTRESOURCE if that''s still the case):
(HICON)LoadImage( hInstance, MAKEINTRESOURCE(IDI_TRAY), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CXSMICON), LR_DEFAULTCOLOR | LR_SHARED ) ;
this will load an icon from the specified icon resource that is the closest match in size to the current "small" icon size specified for the system. you could also use this type of function call for the "large" icon; just substitute SM_CXICON for SM_CXSMICON.
Thanks AP - I tried this:
wc.hIconSm = (HICON)LoadImage(hInstance,MAKEINTRESOURCE(IDI_MAIN),IMAGE_ICON,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CXSMICON),LR_DEFAULTCOLOR|LR_SHARED);
But unfortunately it didnt work
[Edit]
Neither did this:
wc.hIconSm = (HICON)LoadImage(hInstance,(LPCSTR)IDI_MAIN,IMAGE_ICON,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CXSMICON),LR_DEFAULTCOLOR|LR_SHARED);
[/Edit]
[edited by - emileej on November 10, 2003 2:30:24 AM]
wc.hIconSm = (HICON)LoadImage(hInstance,MAKEINTRESOURCE(IDI_MAIN),IMAGE_ICON,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CXSMICON),LR_DEFAULTCOLOR|LR_SHARED);
But unfortunately it didnt work
[Edit]
Neither did this:
wc.hIconSm = (HICON)LoadImage(hInstance,(LPCSTR)IDI_MAIN,IMAGE_ICON,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CXSMICON),LR_DEFAULTCOLOR|LR_SHARED);
[/Edit]
[edited by - emileej on November 10, 2003 2:30:24 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement