News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Question about icons

Started by brixton, June 08, 2005, 09:26:14 PM

Previous topic - Next topic

brixton

If I wanted my program to have a custom icon instead of the standard executable window one, how would I go about it?

Thankyou in advance!  :cheekygreen:
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..

dsouza123

Create the icon using an appropriate tool/program such as image editor,
it can be accessed in Quick Editor in the Tools menu.

Look at the example GENERIC.ASM
along with it's resource file source code RSRC.RC
and the icon MAINICON.ICO that is one of the examples that comes with MASM32.


brixton

If it has no GUI, do I need any ASM code?
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..

Clueless

brixton,
I think that if you have no GUI you can just create the program from the asm file with no icon.  One you have the exe you can click its properties and then add any icon you want.

Gene

Mark Jones

Console apps can have icons just like GUI apps, dsouza123's comments above still apply.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Clueless

Mark,
I realize this, also, but I somehow get the idea he wants to avoid the use of a resource file.  My method allows this to happen.

Gene

Mark Jones

Interesting. I never knew that an .exe's icon could be changed by digging into its properties. Guess we learn something new every day...
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

hutch--

The trick is to work out how a normal resource script is written and how to compile the resource into an executable file. There is no difference between console and GUI apps here. Most console aps don't use resources as they are text mode displays.

Once you have the need for image data like bitmaps and icons, you write the script, compile it and link it into the application. Within the application there are system API calls that load and access this resource data.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Jeff

Quote from: Clueless on June 10, 2005, 01:50:06 AM
brixton,
I think that if you have no GUI you can just create the program from the asm file with no icon. One you have the exe you can click its properties and then add any icon you want.

Gene

unfortunately its not that easy.  that only applies to shortcuts, not executables.

brixton

You can only change the icon with the PIF file (shortcut) to a DOS executable  :U

I have a 32-bit console app.  How do I link with the resource file?   Will QE do this for me?  And do I need any ASM in my app?

Thanks  :P
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..

Mark Jones

Brixton, to make your 32-bit console app have an icon, make a new file called rsrc.rc and in that file include the line:


100 icon discardable "MyIcon.ico"


Then run these two commands to produce an .obj file:

\masm32\bin\rc /v rsrc.rc
\masm32\bin\cvtres /machine:ix86 rsrc.res

Then when you recompile the regular .exe, the rsrc.obj will be included automatically and your icon will appear in the executable. Experiment with the MASM32 examples for more info. :)
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

brixton

Mark Jones,

Quote from: Mark Jones on June 10, 2005, 06:37:40 AM
Brixton, to make your 32-bit console app have an icon, make a new file called rsrc.rc and in that file include the line:


100 icon discardable "MyIcon.ico"


Then run these two commands to produce an .obj file:

\masm32\bin\rc /v rsrc.rc
\masm32\bin\cvtres /machine:ix86 rsrc.res

Then when you recompile the regular .exe, the rsrc.obj will be included automatically and your icon will appear in the executable. Experiment with the MASM32 examples for more info. :)
Thankyou for the info!  Could you explain what the /v switch does, and what cvtres does? 

Sorry for the basic questions  :'(
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..

hutch--

The /v switch is "verbose" so that you can see if the resources built correctly.

CVTRES converts a compiled resource file with a RES extension to an object module so it can be linked into the EXE file as its resource section.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

brixton

Thankyou very much all, I understand now  :bg :dance:
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..

Clueless

Jeff,
Yes, I was referring to the shortcut.  Somehow, if you drop the exe onto the desktop, the OS makes it all work and adding an icon is very easy.  I do it all the time.  It is, IMO, the preferred method for a console app that does not have a need for any other resources.  As far as embedding an icon directly into an exe without a resource script, I would just convert the icon to db strings and put it in the data section.

About cvtres, why bother, I never do.  The linker is quite capable of handling .res files and if it is done this way you can then name the .rc file with the same name as the .asm file, this is something that I prefer for some reason.  But I realize that everyone has there own way of doing things and I applaud Hutch for including all the files necessary for people to do things the way they prefer.  Way to go, Hutch!  :thumbu

Gene


Paul