I was working on associating an icon with a window, and thought i had done everything correctly. I've declared the icon in a .rc file as such

#define big 200
small ICON DISCARDABLE "small.ico"

and set it up in my .asm file

small equ 200

and finally called it when creating the window

invoke LoadIcon, hInstance, small
mov wc.hIconSm, eax

yet this does not want to work for me, can anyone spot why its not doing what i think its supposed to. Thanks for the help.
Posted on 2002-05-05 01:56:37 by zealott
/resource file
MyIcon ICON DISCARDABLE "small.ico"

MyIcon db "MyIcon",0

invoke LoadIcon,hInstance, o$ MyIcon

that's how I do it.... I don't like those cryptic numbers...
after awhile I'll be standing there guessing if 200 was the Icon or
201 was a button or the other way around...
Posted on 2002-05-05 02:04:32 by JimmyClif
Afternoon, zealott.

#define [COLOR=red]big[/COLOR] 200

Shouldn't that be...

#define [COLOR=red]small[/COLOR] 200

Posted on 2002-05-05 02:31:41 by Scronty
hi Zealot
this is what you need ...

in your .rc file...

#define IDI_ICON1 600

in your .inc file...

IDI_ICON1 equ 600

in your .asm file

invoke LoadIcon,hInstance,IDI_ICON1 ;load icon from resource file
invoke SendMessage,hWnd,WM_SETICON,NULL,eax ;tell dialog to set it's icon
Posted on 2002-05-05 02:51:32 by MArtial_Code
Thank you for all the help but I still cant figure out what I am doing wrong, other than not checking what i posted to this board yesterday. I'll try to do a better job of explaining what im doing. First off this is what my .rc file looks like.

#define big 100
big ICON DISCARDABLE "big.ico"

#define small 200
temp ICON DISCARDABLE "small.ico"

2 icons, because i am trying to associate an icon with the program itself and an icon with the window...

My .inc file looks like

big equ 100
small equ 200

and finally my .asm file

invoke LoadIcon, hInstance, big
mov wc.hIcon, eax
invoke LoadIcon, hInstance, small
mov wc.hIconSm, eax

I have tried the previous suggestions but to only marginal success. When I tried Martial_Codes' suggestion it associated the 'big' icon with the program itself, but still no icon associated with the window itself. Then i tried JimmyClifs' suggestion and it actually associated the 'small' icon with the program which was pretty strange. Yea, hopefully i've done a better job explaining what is wrong. The only thing that i think might be wrong is that i am not properly calling invoke LoadIcon because I am trying to load 2 icons. Other than that im lost. Thank you again for all your help.
Posted on 2002-05-05 16:00:43 by zealott
Ok try this way then...

in rc file :

Small ICON small.ico
Big ICON big.ico

in .inc file

szSmallicon db "Small",0
szBigicon db "Big",0

in .asm file

invoke LoadIcon,hInstance,OFFSET szBigicon
mov wc.hIcon,eax
invoke LoadIcon,hInstance,OFFSET szSmallicon
mov wc.hIconSm,eax

That should asign the above icons to your window.
Posted on 2002-05-05 19:28:13 by MArtial_Code
Hmm, i guess a question i should have asked at first is are there rules for an icon, size, color depth and whatnot that would make it not show up?
Posted on 2002-05-06 00:58:26 by zealott
from the platform sdk...
"LoadIcon can only load an icon whose size conforms to the SM_CXICON and SM_CYICON system metric values. Use the LoadImage function to load icons of other sizes"

the standard sizes for an icon are 32x32 and 16x16 pixels. You can find out what values SM_CXICON and SM_CYICON are by calling GetSystemMetrics.

I think color depths of 8 and 16 are ok but 32 may be a problem...
I suggest you try with an icon 8/16 bit depth.
I've attached an icon for you to try. just replace the .zip extension with .ico

It definitely works with my prvious posts.
Posted on 2002-05-06 03:46:33 by MArtial_Code
Hiya agian...
I appreciate all the help i've recieved... but still to no avail, im beginning to think its my machine. But I was wondering if anyone would like to look at my code, i've zipped up the icons, rc, inc and asm file in hopes someone would.
Posted on 2002-05-06 04:43:22 by zealott
rename the rc file

rc contraryres.rc

cvtres /machine:ix86 contraryres.res

d:\masm32\bin\ml /c /coff /Cp /Cx contrary.asm
link /subsystem:windows /debug contrary.obj contraryres.obj

del *.obj

del *.res

<edit> But what about the small icon?</edit>
Posted on 2002-05-06 05:06:23 by bdjames
Hi zealott!

THe problem is rc.exe (resource compiler) ignores your "#define ' lines for words 'big' and 'small'. You should comment 'em out AND WRITE IT PLAIN IN ONE LINE:

//#define big 100
100 ICON DISCARDABLE "big.ico"

//#define small 200
200 ICON DISCARDABLE "small.ico"

Otherwise, rc.exe will not assign numeric IDs to both resources, i.e. you had them defined like "BIG" and "SMALL" in compiled .exe, while calling LoadIcon with numeric ID.

Also, place mov hInstance,eax right after invoke GetModuleHandle, NULL
Posted on 2002-05-06 05:18:20 by Andycar
Yayy.. thanks for the help.. it was the mov hInstance, eax that was messing me up.
Posted on 2002-05-06 05:54:04 by zealott