Windows: Setting the window icon

Started by
22 comments, last by emileej 20 years, 5 months ago
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.
.
Advertisement
quote:Original post by emileej
I have ONE icon. This one icon has TWO dimensions: 32x32 AND 16x16.


Emil Johansen- SMMOG AI designerhttp://smmog.com
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):
(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]
Emil Johansen- SMMOG AI designerhttp://smmog.com

This topic is closed to new replies.

Advertisement