Jump to content
  • Advertisement
Sign in to follow this  
Nokturnal

Adding Icon Resource's

This topic is 4817 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys , i am having trouble adding icon resources to my program. The book i am following in trick's ... by andre lamothe. I am using vc++ 6.0 . I will just explain the steps i ve followed in adding the resources. insert->resource -icon - > imported the icon which was there in the same directory - saved the resource script. This resource script was not added to the project , so i had to add the file manually , the resource script and the header file generated in the appropriate folders. Expanded resource files -> the icon which i had imported had a default name , IDI_ICON1 so i changed it to IDI_MYICON In the IDE , opened resource.h and made hte following change :- #define IDI_MYICON 101 left the rest of the overhead intact. included the resource.h file in the main.cpp (which has winmain) #include "resource.h" made the fllowing changes to the code of window class wcx.hIconSm=LoadIcon(NULL,MAKEINTRESOURCE(IDI_MYICON)); wcx.hIcon=LoadIcon(NULL,MAKEINTRESOURCE(IDI_MYICON)); Now the thing displays a exclamation icon instead of the icon i ve chosen. Any suggestions to what i am doing wrong ??

Share this post


Link to post
Share on other sites
Advertisement
LoadIcon(NULL, xxx) loads a stock icon - where 101 appears to be the question mark - not icons that are stored in the resource file. To load your icon, you must pass a valid HINSTANCE. If you are loading an icon that is in your module resource, you can do:


LoadIcon(GetModuleHandle(NULL), xxxx);


HTH,

Share this post


Link to post
Share on other sites
You're not passing in your instance handle, so Windows is loading it from the default icon library. Try LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_MYICON)) if you don't have direct access to your instance handle (as in WinMain).

edit: beaten >_<

Share this post


Link to post
Share on other sites
Thanks , will try that out right now

edit :- Killer , works like a charm .

There is another thing i noticed , the Icon has two sizes 16 x 16 & 32 x 32 , the image which both project is different (I guess one if for hIcon and another for hIconSm ) on launching the application displayed the 16 x 16 image , and on launching it again it is displaying the 32 x 32 icon on the title bar & minimized , since both the lines on where i am assigning the icon resource are the same , when is the 16 x 16 displayed and when is the 32 x 32 displayed , is there a way to force either one of them to be displayed ?

thanks

[Edited by - Nokturnal on June 8, 2005 6:36:11 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!