• Advertisement

Archived

This topic is now archived and is closed to further replies.

----- cant display icon ---------

This topic is 5828 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 everybody, i use to load icon, the function LoadIcon(hInst, ?); when i use LoadIcon(hInst, "c:\iconName.ico"); it doesnt work (file iconname.ico exists of course) compilation works, execution works, but icon doesnt appear on explorer!! so i add this iconFile to apps resource (RC file) when i use LoadIcon(hInst, MAKEINTRESOURCE (ICO_APPS));; it doesn''t work too !!! compilation works, execution works, but ...icon doesnt appear X-( there is a question now : HOW CAN I DISPLAY AN ICON ??????? or HOW CAN I AFFECT AN ICON TO MY PROG ????? thanx a lot

Share this post


Link to post
Share on other sites
Advertisement
Double check that you have ICO_APPS defined in a header that is included in both the rc file and the source file. Also check that you have declared the ICON in the rc properly. Lastly, make certain that the hInst variable isn't null but actually comes from your program - that is if you're passing it to a helper func that fills in the WNDCLASS structure rather than doing so from inside WinMain. Since the program runs, I suspect the problem rests in the way you've declared the ICON in the rc file. Also - sometimes resource compilers choke on 32 bit ints so you might want to keep the rc_id value in the positive range of signed shorts 0 - 32767, that is, 16 bits.

Edited by - lessbread on February 2, 2002 11:36:39 PM

Share this post


Link to post
Share on other sites
The first version will never work because LoadIcon will only work for resources. Use LoadImage to load an icon (or cursor or bitmap) from a file.

Anyway.

You usually don''t have to store the app''s instance handle because GetModuleInstance(NULL) will give it to you.

Make sure your .rc file is part of your project. If it is, there''s only one other thing I can think of. I know that recently I had some issues with volatile variables causing the resource section not to be included in the executable at all. Assuming Visual C++... Build your app. Then close your project. Open your executable in Visual C++ using the Resource mode and make sure your resources are actually in there. If they''re not, I don''t know what to tell you. If they are, I don''t know what to tell you, either.

Share this post


Link to post
Share on other sites
thanks a lot, it works now ..... :-)

but icons are not transparent, there is a black background !
how to define a transparent color ?

Share this post


Link to post
Share on other sites
What was the problem, by the way?

The editor you use to make your icon will have two special colors. On for "transparent" and one for "invert". So, for transparency (assuming non-Windows XP 32-bit icons, use the "transparent" color). If you''re drawing them in Visual C++, the special colors are in little icons that look like monitors near the other colors.

Share this post


Link to post
Share on other sites

  • Advertisement