Hi all,
Is it possible use PB to compile an exe such that we embed multiple icons in it? i.e. not just multiple versions of the same icon at different sizes/colour depths, but multiple different icons, that can be referred to by index when creating shortcuts.
In the compiler options, there is just a choice of .ico file. And it seems that I can't put multiple icons in a single .ico - at least, IcoFX won't let me create multiple icons with the same size and colour depth in a single .ico file.
It's clearly doable though, - purebasic itself has multiple icons in the exe for the IDE.
If I can't do this natively presumably I need to not do an icon at all in PB, and do something with the SDK tools (rc.exe?) after compiling?
[SOLVED] Compiling an exe with multiple icons in it.
[SOLVED] Compiling an exe with multiple icons in it.
Last edited by mikejs on Tue Sep 12, 2023 10:03 am, edited 1 time in total.
Re: Compiling an exe with multiple icons in it.
Code: Select all
; CompilerIf #PB_Compiler_OS = #PB_OS_Linux
; ; https://www.purebasic.fr/english/viewtopic.php?p=531374#p531374
; ImportC ""
; gtk_window_set_icon(a.l,b.l)
; EndImport
; CompilerEndIf
UseGIFImageDecoder() ; + 15 kb
; UsePNGImageDecoder() ; png? + 150 kb
DataSection
IconTitle:
IncludeBinary "images" + #PS$ + "title.gif"
link:
IncludeBinary "images" + #PS$ + "link.gif"
calculate:
IncludeBinary "images" + #PS$ + "calculate.gif"
copy:
IncludeBinary "images" + #PS$ + "copy.gif"
insert:
IncludeBinary "images" + #PS$ + "insert.gif"
set:
IncludeBinary "images" + #PS$ + "set.gif"
EndDataSection
CatchImage(0, ?IconTitle)
CatchImage(3, ?link)
CatchImage(1, ?calculate)
CatchImage(2, ?copy)
CatchImage(4, ?insert)
CatchImage(5, ?set)
Debug ImageID(0)
Debug ImageID(1)
Debug ImageID(2)
Debug ImageID(3)
Debug ImageID(4)
Debug ImageID(5)
; CompilerIf #PB_Compiler_OS = #PB_OS_Linux
; gtk_window_set_icon_(WindowID(#Window), ImageID(0))
; CompilerEndIf
Re: Compiling an exe with multiple icons in it.
Purebasic installation comes with Pelles Resource Compiler.
create a .rc file like this:
and compile it to a res file.
The resulting Icons.res can be imported by Purebasic code.
create a .rc file like this:
Code: Select all
#define LANG_NEUTRAL 0
#define SUBLANG_NEUTRAL 0
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
100 ICON "ICON100_1.ico"
101 ICON "ICON101_1.ico"
ABC ICON "ICONABC.ico"
Code: Select all
%PUREBASIC_HOME%\Compilers\porc.exe /R D:\WORK\Icons.rc.
Code: Select all
Import Icons.res
EndImport
Re: Compiling an exe with multiple icons in it.
I have not used IcoFX. I use "greenfish icon editor" and you are able to save multiple icons of the same size and color depth:
(Freeware and Portable)
http://greenfishsoftware.org/gfie.php#apage
Norm.
(Freeware and Portable)
http://greenfishsoftware.org/gfie.php#apage
Norm.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
Re: Compiling an exe with multiple icons in it.
I think that mikejs is not asking to include as many icons in the exe file
But he is asking to compile an exe file with many icons that he can use exe properties to change the icon at any time
fryquez is the right way to do that except you don't need to compile the rc file
But just use PB compiler options to add the rc file directly
I hope I am right
But he is asking to compile an exe file with many icons that he can use exe properties to change the icon at any time
fryquez is the right way to do that except you don't need to compile the rc file
But just use PB compiler options to add the rc file directly
I hope I am right

Egypt my love
Re: Compiling an exe with multiple icons in it.
Yes, I do it like this and it gives the same result as fryquez.RASHAD wrote: Mon Sep 11, 2023 6:30 pm But just use PB compiler options to add the rc file directly
I hope I am right
Create a .rc file (ex: Icons\Icon.rc) with for example:
Code: Select all
2 ICON "Icons/ICON2.ico"
100 ICON "Icons/ICON100.ico"
Re: Compiling an exe with multiple icons in it.
Thanks all, the above works perfectly.ChrisR wrote: Mon Sep 11, 2023 6:50 pmYes, I do it like this and it gives the same result as fryquez.RASHAD wrote: Mon Sep 11, 2023 6:30 pm But just use PB compiler options to add the rc file directly
I hope I am right
Create a .rc file (ex: Icons\Icon.rc) with for example:
And in compiler options, resources tab, just add Icons\Icon.rcCode: Select all
2 ICON "Icons/ICON2.ico" 100 ICON "Icons/ICON100.ico"