Archived

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

ranxact

Loading an Icon?

Recommended Posts

hey.. hate to bother everyone w/ wuch a stupid question... but how do i load a specific ICON? i have one in my recources.. but i can''t seem to get it loaded... wc.hIcon = LoadIcon(hInstance, ??????? ); i tried the icon name, but it wasn''t defined... again sorry for such a silly question, but in the books i have they either use a wizard, or MFC, or the default allpication icon... and this doesn''t help... ThanX, RanXacT

Share this post


Link to post
Share on other sites
depends on how you set up your cursor resource but try using MAKEINTRESOURCE.

wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(icon goes here);

dont quote me on the syntax but im pretty sure MAKEINTRESOURCE will solve your problem

Share this post


Link to post
Share on other sites
I just use syntax

wc.hIcon = LoadIcon(hInstance, "Icon1");

and that works just fine for me...it sounds like you tried to use the icon name as a variable instead of a string representation of it, I''m pretty sure but don''t kill me if I''m wrong, but you can''t have a definition like

#define Icon1 1

in your .rh file or .rc file, because I think that''ll screw up at least this way of loading =)

Share this post


Link to post
Share on other sites

I knew it was sonme little thing...

wc.hIcon = LoadIcon(hInstance, "Icon1"); // works


as for MAKEINTRESOURCE , where is it defined? i can''t find the definition of it... that is what i first tried, but i couldn''t figure it out....is it in MFC ?

ThanX All,
RanXacT

Share this post


Link to post
Share on other sites
MAKEINTRESOURCE is used to retrieve the information that you have put in a resource area. It''s a WIN32 macro. If you have loaded a resource into your resource area, you can access it by passing MAKEINTRESOURCE the name of the resource, which will extract it for you. (The reason for putting things in the resource would of course be the fact that you then would not have to send the .ico''s and everything else with the executable, it would be made part of the executable when you compile) This is the safest way to reference an icon out of your resource area.

As for LoadIcon, it''s obsolete. You should probably be using LoadImage.

-fel

Share this post


Link to post
Share on other sites