Author Topic: icons into the exe  (Read 5421 times)

Offline MoonKid

  • Almost regular
  • **
  • Posts: 180
icons into the exe
« on: April 26, 2008, 07:30:56 pm »
How can I compile icons (png, ico, ...) in the exe file, so that the binary is shown with this symbol instead of the standard-win32-exe symbol?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: icons into the exe
« Reply #1 on: April 27, 2008, 09:08:01 am »
Create a resource file and name the first (your) icon resource "AAAAAAAAAAEXEICON". (No, these awful "A"'s are not an error.) Thus you "place" this icon to be the first resource. Windows will pick the first resource as icon for the executable. Make sure you add the resource file to your project so that it's being compiled / linked... ;-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MoonKid

  • Almost regular
  • **
  • Posts: 180
Re: icons into the exe
« Reply #2 on: April 27, 2008, 06:28:47 pm »
Nice it works.

Which format need this icon to have. This time I use a 16x16 ICO file.

But what is about a bigger view?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: icons into the exe
« Reply #3 on: April 27, 2008, 08:01:46 pm »
But what is about a bigger view?
An icon file can actually hold more than one icon in several resolutions (16x16, 32x32, 64x64...) and several color depths. You can use tools like IcoFX (http://icofx.ro/) to create such "combined" icon files. Windows is so clever - it will choose just the right resolution/color depth at runtime which depends on the resolution / color depth of the OS on the target machine (obviously).

Although such "cleverness" I found no way to tell Windows *not* to take the first resource as application icon. :? That's why I suggested "AAAAA..." in front. If you find a "right" solution - step forward. ;-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Jeisson

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: icons into the exe
« Reply #4 on: April 28, 2008, 10:47:12 pm »
Morten. Can those icon files be used only with MsWindows?. When I compile the project in Linux, they generate non-fatal runtime errors and finally they are not shown. Should I generate both, .ico (for .rc file) and xpm files in any other place (frames, menus...)?

A derivated question. How can I skip compiling the .rc file under Linux?

Thanks a lot for your kindness.
Best regards.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: icons into the exe
« Reply #5 on: April 29, 2008, 07:49:22 am »
Can those icon files be used only with MsWindows?
Yes. Under Linux you need an XPM (which can hold several "icons" again). Search the wxWidgets examples - there are plenty  of Windows / Linux projects with icon resources. You'll find the required switchyard, too. (I don't recall atm).

How can I skip compiling the .rc file under Linux?
Either you use scripting (attach a script file to your project that turns off compilation under other platforms than Windows) of you just create another (Linux) target / project. I personally use the latter... although much more "cool" is the first. ;-) (But I am too lazy to change all my projects.)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: icons into the exe
« Reply #6 on: April 29, 2008, 10:04:28 am »
If you leave the resource compiler textfield empty in your linux configuration (that's the default), you can have the .rc-file as part of your project on linux and windows, it's just skipped when compiling the sources:
Code
Skipping file (no compiler program set): SPS_Log.rc

svn5021 on debian

Offline Jeisson

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: icons into the exe
« Reply #7 on: May 01, 2008, 12:00:19 am »
Thanks Morten and Jens. I will replace the few .ico files I have in my project for xpm ones, and I feel glad for that. I think to learn Gimp.

About skipping the .rc file. I have two build targets, one for Linux, another for Windows. Always that I compile the first one, the instruction "Skipping file (no compiler program set)" is shown. Now I feel confidence to ignore it. But I always try to keep my project compiling with 0 warnings :D. I am wondering if is possible to move the <Unit filename="..myfile.rc"> from the global <Project> section to the MsWindows <Target> section?

Thanks again for your valuable help.
Greetings.