Better Way Of Handling CreateImageMenu() Images
Posted: Sun Jan 20, 2013 6:15 am
Currently the form designer generates code like this for handling images for a image menu.
The problem is you have to distribute the icons with your program, and in the same directory hard coded into the application. Which is highly unconventional. So I think this should be changed (hopefully before 5.10 release). I have outlined example below of how to pack the icons with the executable itself.
This way your menu's can have icons, while also having a single .exe without any trailing data. It would be also nice if you are opening icons with the form designer in the same folder as the .pbf file. That it resolves paths to "Folder\Image.png" so you don't have to keep messing with the source each time you want to compile from a different location on your machine (see example above).
Also note: You are missing spaces in the following functions.
Code: Select all
UsePNGImageDecoder()
Img_0 = LoadImage(#PB_Any,"C:\Users\Admin\Desktop\Editor\Icon\Open.png")
MenuItem(#MenuItem_2,"Open", ImageID(Img_0))
Code: Select all
DataSection
Image1: IncludeBinary "Icon\Open.png"
Image2: IncludeBinary "Icon\Save.png"
EndDataSection
UsePNGImageDecoder()
CatchImage(1, ?Image1)
CatchImage(2, ?Image2)
MenuItem(#MENU_1, "Open", ImageID(1))
MenuItem(#MENU_2, "Save", ImageID(2))Also note: You are missing spaces in the following functions.
MenuItem(#MenuItem_2,<here>"Open", ImageID(Img_0))
LoadImage(#PB_Any,<here>"C:\Users\Admin\Desktop\Editor\Icon\Open.png")
