Including icons into code
Including icons into code
Dear forum users,
is there some way to include all program icons into the code? I want to get only one executable file, without any additional icon files, but I can't find how to do that.
Thanks in advance for all suggestions.
Best regards
is there some way to include all program icons into the code? I want to get only one executable file, without any additional icon files, but I can't find how to do that.
Thanks in advance for all suggestions.
Best regards
Re: Including icons into code
Code: Select all
DataSection
MyIcon:
IncludeBinary "MyIconFile.ico"
EndDataSection
CatchImage(#Icon, ?MyIcon)
Re: Including icons into code
You're great!
Thank you.
Thank you.
Re: Including icons into code
Yet another problem:
if I use:
everything is ok,
but in this case:
icon on the button disappears after first clickink on it.
What am I doing wrong?
I use PB 5.62 x64 on Linux.
if I use:
Code: Select all
ButtonImageGadget(#BtnIdManHdec,
ScaleDPIx(20), ScaleDPIy(19),
ScaleDPIx(20), ScaleDPIy(14),
ImageID(LoadImage(#PB_Any, "ICO/arrow_left.png")))
but in this case:
Code: Select all
ButtonImageGadget(#BtnIdManHdec,
ScaleDPIx(20), ScaleDPIy(19),
ScaleDPIx(20), ScaleDPIy(14),
CatchImage(0, ?ArrowLeftIco))
What am I doing wrong?
I use PB 5.62 x64 on Linux.
Re: Including icons into code
Code: Select all
ImageID(CatchImage(0, ?ImageLabel))
Re: Including icons into code
Thank you again, it works now, but with a little exeption:
Thanks!
Code: Select all
ImageID(CatchImage(#PB_Any, ?ImageLabel))
Re: Including icons into code
This is my first post. I decided to give PB a try over another competitive product and i created a small exe that opens a form and loads buttons (png files). The program runs but i need to clarify someηting. The code is the following:
My question is this.. in order to create an image DO i need to initialise the #image variable?
How does ButtonImageGadget work here if i havent loaded or created an image?
At some point it was complaining that i did not initialise an image and i do not remember what change i made and it stopped. The idea for all this is to include the image in the .app file.
Code: Select all
DataSection
Archive:
IncludeBinary "icons_48/Archive.png"
Bank:
IncludeBinary "icons_48/Bank.png"
Bsman:
IncludeBinary "icons_48/businessman.png"
money:
IncludeBinary "icons_48/money-bag.png"
safebox:
IncludeBinary "icons_48/safebox.png"
cityscape:
IncludeBinary "icons_48/cityscape.png"
EndDataSection
Procedure MyToolBar()
UsePNGImageDecoder()
ButtonImageGadget(0, 0, 0, 60, 60, ImageID(CatchImage(#PB_Any, ?Archive)), #PB_Button_Toggle)
ButtonImageGadget(1, 60, 0, 60, 60, ImageID(CatchImage(#PB_Any, ?Bank)), #PB_Button_Toggle)
ButtonImageGadget(2, 120, 0, 60, 60, ImageID(CatchImage(#PB_Any, ?bsman)), #PB_Button_Toggle)
ButtonImageGadget(3, 180, 0, 60, 60, ImageID(CatchImage(#PB_Any, ?money-bag)), #PB_Button_Toggle)
ButtonImageGadget(4, 240, 0, 60, 60, ImageID(CatchImage(#PB_Any, ?safebox)), #PB_Button_Toggle)
ButtonImageGadget(5, 300, 0, 60, 60, ImageID(CatchImage(#PB_Any, ?cityscape)), #PB_Button_Toggle)
EndProcedure
How does ButtonImageGadget work here if i havent loaded or created an image?
At some point it was complaining that i did not initialise an image and i do not remember what change i made and it stopped. The idea for all this is to include the image in the .app file.
"A good beginning is half the task"
Mac OSX 10.13.3 - PureBasic 5.62 (MacOS X - x64)
Mac OSX 10.13.3 - PureBasic 5.62 (MacOS X - x64)
Re: Including icons into code
technically you have been creating the images with CatchImage() - this command loads an image from memory
ordinarily, I'd load all my images with specific image_numbers, and then assign them to the ButtonImageGadgets by number (this way you can reuse images easily without having to reload them - helps with memory usage too)
ordinarily, I'd load all my images with specific image_numbers, and then assign them to the ButtonImageGadgets by number (this way you can reuse images easily without having to reload them - helps with memory usage too)
there is no sig, only zuul (and the following disclaimer)
WARNING: may be talking out of his hat
WARNING: may be talking out of his hat
Re: Including icons into code
Thank you. Your answer saved me hours of searching.
"A good beginning is half the task"
Mac OSX 10.13.3 - PureBasic 5.62 (MacOS X - x64)
Mac OSX 10.13.3 - PureBasic 5.62 (MacOS X - x64)