Hello,
I am currently at tutotial #9, so I am not the asm light. I wish to add an icon on the top left of a window.

I figured that the LoadIcon in the creation of the window is what I need to play with.

I got this from user32.inc :
LoadIconA PROTO :DWORD,:DWORD
LoadIcon equ <LoadIconA>
and from the API:
HICON LoadIcon(
HINSTANCE hInstance, // handle of application instance
LPCTSTR lpIconName // icon-name string or icon resource identifier);

So:
......
.const
MyIcon equ 1 ; Icon IDs
......
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
........
invoke LoadIcon,NULL,MyIcon
mov wc.hIcon,eax
mov wc.hIconSm,eax

should do the trick with the inclusion of the icon in the script of MyResource.rc file.

What is the script to include an icon in the resource file?

thank you

cdnhermit
Posted on 2001-12-22 23:41:48 by cdnhermit
for example somthing like this

#define MyIcon 1


MyIcon ICON "install.ico"
Posted on 2001-12-23 01:05:32 by Allanon
use:

invoke LoadIcon, hInstance, 7000 ; 7000 is code in resource file
mov hIcon, eax

mov wc.hIcon, eax
mov wc.hIconSm, eax

AND.. In your "rsrc.rc" file (if you use Hutch's package to generate a new project), other wise anything.rc, simply ADD :

7000 ICON "myIcon.ico"

Remember that the number "7000" in this case should be unique in your program ID's. It can also be a name but i prefer #'s.

Lastly remember to re-build your RSRC.RC file (using the rc.exe) as well as your program. And the file "myIcon.ico" should be in the directory..

Hope This helps.
NaN
Posted on 2001-12-23 01:11:05 by NaN
Thank you NaN

I could make it work without the second line of code:
mov hIcon, eax

Than you

cdnhermit
Posted on 2001-12-23 11:39:03 by cdnhermit
cdnhermit,


I could make it work without the second line of code:
mov hIcon, eax


Of course, this second line is to store the handle that will identify the icon
Posted on 2001-12-23 14:17:34 by CodeLover
Thank you CodeLover I had remove the line because hIcon was not define and I did not know what to do. I figured that I needed to add

hIcon HINSTANCE ? in .data?

I hope I got it right. It works anyway

thanks for coming back

cndhermit
Posted on 2001-12-23 22:31:01 by cdnhermit