Advertisement

Loading an Icon?

Started by March 29, 2000 04:15 PM
3 comments, last by ranxact 24 years, 5 months ago
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
RanXact@yahoo.com
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
There's always something smaller and something bigger. Don't sweat the small stuff and don't piss off the big stuff :)
Advertisement
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 =)
Chris

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
RanXact@yahoo.com
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
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~

This topic is closed to new replies.

Advertisement