Re: Icons and exe files
- Posted by jacquesd Aug 07, 2008
- 953 views
Using the following command, I can inject a desktop icon into an exe file compiled with Watcom:
wrc -q -ad myrcfile.rc myexefile.exe
The myrdfile.rc has a single line:
MYEXEFILE ICON MYICONFILE.ICO
This works fine for the desktop icon. However, the icon at the top left of each window in the application itself remains "unassigned" or at least it appears that way.
What is the accepted method for setting the icon in the application (as opposed to the desktop icon)?
Thanks
Mike
I don't know about win32lib but with direct win32 API the following should work.
Modify your .RC file to put and identifier for the icon before compiling and binding it to the binary. That way you'll know which id to use in the call.
MYEXEFILE ICON MYICONFILE.ICO 100
You should check for the correct .rc file syntax.
-- setting a windows icon from an icon resource in binary file -- icon_id is an integer that identify the icon inside the binary file. -- all resources in windows binaries have an identifier. include dll.e constant user32=open_dll("user32.dll") constant iSetClassLong=define_c_func(user32,"SetClassLong",{C_ULONG,C_INT,C_ULONG},C_ULONG) constant GCL_HICON = -14 constant ID_ICON = 100 object void sequence cmd_line cmd_line = command_line() if equal(cmd_line[1],cmd_line[2]) then -- check if it is a binary file void = c_func(iSetClassLong,{hWnd,--window handle GCL_HICON, ID_ICON -- icon resource identifier }) else -- load resource from .ico file ... end if
Jacques