Thanks Demivec for posting your commented code and links, they will help new users to PB better understand some of its inconsistency due to its flexibility
Sorry my first post was not very good and I should not have added any of the #PB_Any stuff. I tried to clear things up a little better in my second post but failed also.
As per my post title, GetGadgetAttribute returns an ImageID (handle) which does not work with PB's Image commands (which can be considered a bug or an oversight).
Both mestnyi and Josh get what I was trying to say and Josh even posted a workaround... and yes, this may be better suited for the Feature Request section.
For anyone else following this thread, I'll try my hardest to clear up the confusing mess I've made here due to my inability to convert thoughts into coherent text
Due to PB's flexibility you can have 3 different ways to represent the Image...
hImage=CreateImage(#IMG,w,h) <-- hImage is the ImageID OR #IMG is the Image#
hImage=CreateImage(#PB_Any,w,h) <-- hImage is the Image#
(and the inconsistency ... hImage is an ImageID
UNLESS #PB_Any is used then
hImage is Image#)
Gadgets that use images all use the ImageID...
ButtonImageGadget(Gadget,x,y,w,h,hImage) <-- if hImage already contains the ImageID
ButtonImageGadget(Gadget,x,y,w,h,ImageID(#IMG)) <--if you are using the Image# it must be converted to ImageID with ImageID()
ButtonImageGadget(Gadget,x,y,w,h,ImageID(hImage)) <--if #PB_Any was used then hImage which is actually Image#, must be converted to ImageID with ImageID()
API calls use hImage (handle) which we either have from PB's ability to provide a handle upfront OR we are provided with ImageID() to use with the Image# to get the handle.
PB Image Commands only use the Image#... ImageWidth(#IMG)
(and the inconsistency... There is no native command to get the Image# from the hImage/handle)
YES, we need GetImageFromHandle(hImage)
This can also be applied to other PB commnds.. GetGadgetFromHandle(hGadget), GetWindowFromHandle(hWindow), etc.
When a command like ImageWidth() can only make use of the Image# even though an Image might have Image# OR ImageID and there is only a command for one way conversion (ImageID()--> hImage) ... this seems to be a bit of a problem. If there was a GetImageFromHandle(hImage) command, this entire post would have been avoided.