Julian wrote:...a lot of people use the form designer, which doesn't automatically insert a nice structure for tracking added images/gadgets etc.
That ultimately means if I want to make a module to alter those and make it a drop in solution, people need to register the images with my module first.
Hi Julian. Until the team implements the long-lamented
GetImageNumber(fromImageID) function, here's a simple drop-in solution that might work for you.
It's comprised of two short procedures, one to initialise all the images in a project, and another to return the image number from the given image ID:
Code: Select all
;does not work well when images are initialised with #PB_Any as
;PureBasic's #PB_Any initialises objects with very high numbers
Procedure initImages()
Global NewMap images.i()
For i = 0 To 1000 ;adjust accordingly
If IsImage(i)
images(Str(ImageID(i))) = i
EndIf
Next i
EndProcedure
Procedure.i GetImageNumber(imgID.i)
result = -1
If FindMapElement(images(), Str(imgID))
result = images(Str(imgID))
EndIf
ProcedureReturn result
EndProcedure
initImages()
Debug GetImageNumber(validImageID)
The only limitation of this solution is that it does not work well with images initialised with
#PB_Any, as the auto-generated numbers are very high and would require bigger loops to find all the images.
Nevertheless, hope you'd find it useful.
